Browse code

vimrc - v1.3 - Update settings for Vim 9 compatibility

Fred authored on22/12/2025 18:01:39
Showing1 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2 2
 " Versions
3 3
 "
4
+" v1.3 - 2025-12-22: add commands to set interface colors and transparency / Set file types for specific extensions
4 5
 " v1.2 - 2024-08-07: remove trailing whitespace
5 6
 " v1.1 - 2020-08-16: status line improved / comment symbol for R filetype added / comment shortcut improved / replacement shortcut improved / tabedit shortcut improved
6 7
 " v1.0 - 2020-03-15: backup, undo and swap improved / text duplication mapping / search and replace mapping / plugins added / code cleaned
... ...
@@ -195,6 +196,15 @@ set encoding=utf8
195 196
 " Use Unix as the standard file type
196 197
 set ffs=unix,dos,mac
197 198
 
199
+" Transparent background
200
+autocmd vimenter * hi Normal guibg=NONE ctermbg=NONE
201
+autocmd vimenter * hi EndOfBuffer guibg=NONE ctermbg=NONE
202
+
203
+" Tab colors
204
+autocmd vimenter * hi TabLineSel term=bold cterm=bold gui=bold ctermbg=None ctermfg=white
205
+autocmd vimenter * hi TabLine term=underline cterm=underline ctermfg=15 ctermbg=242 gui=underline guibg=DarkGrey
206
+autocmd vimenter * hi TabLineFill term=reverse cterm=reverse gui=reverse
207
+
198 208
 
199 209
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
200 210
 " => Files, backups and undo
... ...
@@ -260,6 +270,9 @@ set wrap "Wrap lines
260 270
 " Comment symbol for filetype
261 271
 autocmd FileType r setlocal commentstring=#\ %s
262 272
 
273
+" Set file types for specific extensions
274
+autocmd BufRead,BufNewFile *.smk setlocal filetype=python
275
+
263 276
 " Remove trailing whitespace
264 277
 " Note: use *.{sh,R,etc} to restrict filetype
265 278
 autocmd BufWritePre * :%s/\s\+$//e
... ...
@@ -341,7 +354,7 @@ au InsertChange * call InsertStatuslineColor(v:insertmode)
341 354
 au InsertLeave * hi statusline term=reverse ctermfg=15 ctermbg=0
342 355
 
343 356
 " Default the statusline when entering Vim
344
-hi statusline term=reverse ctermfg=15 ctermbg=0
357
+hi statusline term=reverse cterm=bold,reverse ctermfg=15 ctermbg=0
345 358
 
346 359
 " Format the status line
347 360
 set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ \ Col.:\ %c
Browse code

vimrc - v1.2 - Remove trailing whitespace

Fred authored on07/08/2024 16:58:17
Showing1 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2 2
 " Versions
3 3
 "
4
+" v1.2 - 2024-08-07: remove trailing whitespace
4 5
 " v1.1 - 2020-08-16: status line improved / comment symbol for R filetype added / comment shortcut improved / replacement shortcut improved / tabedit shortcut improved
5 6
 " v1.0 - 2020-03-15: backup, undo and swap improved / text duplication mapping / search and replace mapping / plugins added / code cleaned
6 7
 " v0.4 - 2019-11-20: backup, undo and swap added
... ...
@@ -259,6 +260,10 @@ set wrap "Wrap lines
259 260
 " Comment symbol for filetype
260 261
 autocmd FileType r setlocal commentstring=#\ %s
261 262
 
263
+" Remove trailing whitespace
264
+" Note: use *.{sh,R,etc} to restrict filetype
265
+autocmd BufWritePre * :%s/\s\+$//e
266
+
262 267
 
263 268
 """"""""""""""""""""""""""""""
264 269
 " => Visual mode related
Browse code

vimrc - v1.1 - See Versions section for details

Fred authored on16/08/2020 23:30:31
Showing1 changed files
... ...
@@ -1,8 +1,9 @@
1 1
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2 2
 " Versions
3 3
 "
4
-" v1.0 - 2020-03-15: Backup, undo and swap improved / text duplication mapping / search and replace mapping / plugins added / code cleaned
5
-" v0.4 - 2019-11-20: Backup, undo and swap added
4
+" v1.1 - 2020-08-16: status line improved / comment symbol for R filetype added / comment shortcut improved / replacement shortcut improved / tabedit shortcut improved
5
+" v1.0 - 2020-03-15: backup, undo and swap improved / text duplication mapping / search and replace mapping / plugins added / code cleaned
6
+" v0.4 - 2019-11-20: backup, undo and swap added
6 7
 " v0.3 - 2019-07-07: Vundle installation detection
7 8
 " v0.2 - 2015-02-19: Vundle added
8 9
 " v0.1 - 2014-10-19: variable for screen integration set / commands for (un)commenting block added / no backup behavior
... ...
@@ -172,6 +173,9 @@ set novisualbell
172 173
 set t_vb=
173 174
 set tm=500
174 175
 
176
+" Set time out between keystroke
177
+set timeoutlen=300
178
+
175 179
 
176 180
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
177 181
 " => Colors and Fonts
... ...
@@ -252,6 +256,9 @@ set ai "Auto indent
252 256
 set si "Smart indent
253 257
 set wrap "Wrap lines
254 258
 
259
+" Comment symbol for filetype
260
+autocmd FileType r setlocal commentstring=#\ %s
261
+
255 262
 
256 263
 """"""""""""""""""""""""""""""
257 264
 " => Visual mode related
... ...
@@ -296,7 +303,7 @@ map <leader>tm :tabmove
296 303
 
297 304
 " Opens a new tab with the current buffer's path
298 305
 " Super useful when editing files in the same directory
299
-map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
306
+map <leader>te :tabedit <c-r>=fnameescape(expand("%:p:h"))<cr>/
300 307
 
301 308
 " Switch CWD to the directory of the open buffer
302 309
 map <leader>cd :cd %:p:h<cr>:pwd<cr>
... ...
@@ -323,6 +330,14 @@ set viminfo^=%
323 330
 " Always show the status line
324 331
 set laststatus=2
325 332
 
333
+" Change the status line based on mode
334
+au InsertEnter * call InsertStatuslineColor(v:insertmode)
335
+au InsertChange * call InsertStatuslineColor(v:insertmode)
336
+au InsertLeave * hi statusline term=reverse ctermfg=15 ctermbg=0
337
+
338
+" Default the statusline when entering Vim
339
+hi statusline term=reverse ctermfg=15 ctermbg=0
340
+
326 341
 " Format the status line
327 342
 set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ \ Col.:\ %c
328 343
 
... ...
@@ -344,8 +359,11 @@ vmap <C-d> :'<,'>t'><cr>'[O<Esc>
344 359
 nmap <C-d> yyp
345 360
 
346 361
 " Search and replace
347
-nnoremap <leader>h y:<C-U>let replacement = input('Enter replacement string: ') <bar> %s//\=replacement/gc<CR>
348
-xnoremap <leader>h y:<C-U>let replacement = input('Enter replacement string: ') <bar> %s/<C-R>"/\=replacement/gc<CR>
362
+nnoremap <leader>h y:<C-U>let replacement = input('Enter replacement string: ') <bar> s//\=replacement/gc<CR>
363
+xnoremap <leader>h y:<C-U>let replacement = input('Enter replacement string: ') <bar> s/<C-R>"/\=replacement/gc<CR>
364
+
365
+nnoremap <leader>hh y:<C-U>let replacement = input('Enter replacement string: ') <bar> %s//\=replacement/gc<CR>
366
+xnoremap <leader>hh y:<C-U>let replacement = input('Enter replacement string: ') <bar> %s/<C-R>"/\=replacement/gc<CR>
349 367
 
350 368
 " Delete trailing white space on save, useful for Python and CoffeeScript ;)
351 369
 func! DeleteTrailingWS()
... ...
@@ -420,8 +438,9 @@ nnoremap <f8> :set hlsearch!\|set hlsearch?<cr>
420 438
 " Clear search
421 439
 map <leader>c :let @/=""<CR>
422 440
 
423
-" (Un)comment block of text (depend on commentary-vim plugin)
424
-vmap <C-M> gc
441
+" (Un)comment block of text (depends on commentary-vim plugin) (works with C-/)
442
+vmap <C-_> gc
443
+nmap <C-_> gcc
425 444
 
426 445
 
427 446
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
... ...
@@ -483,3 +502,14 @@ function! <SID>BufcloseCloseIt()
483 502
      execute("bdelete! ".l:currentBufNum)
484 503
    endif
485 504
 endfunction
505
+
506
+" Status line color on mode
507
+function! InsertStatuslineColor(mode)
508
+  if a:mode == 'i'
509
+    hi statusline term=reverse ctermfg=166 ctermbg=0
510
+  elseif a:mode == 'r'
511
+    hi statusline term=reverse ctermfg=160 ctermbg=0
512
+  else
513
+    hi statusline term=reverse ctermfg=5 ctermbg=0
514
+  endif
515
+endfunction
Browse code

vimrc - v1.0 - See Versions section for details

Fred authored on15/03/2020 23:00:55
Showing1 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2 2
 " Versions
3 3
 "
4
+" v1.0 - 2020-03-15: Backup, undo and swap improved / text duplication mapping / search and replace mapping / plugins added / code cleaned
4 5
 " v0.4 - 2019-11-20: Backup, undo and swap added
5 6
 " v0.3 - 2019-07-07: Vundle installation detection
6 7
 " v0.2 - 2015-02-19: Vundle added
... ...
@@ -73,10 +74,7 @@ let mapleader = ","
73 74
 let g:mapleader = ","
74 75
 
75 76
 " Fast saving
76
-"nmap <leader>w :w!<cr>
77
-
78
-" Set 256 colors
79
-set t_Co=256
77
+nmap <leader>w :w!<cr>
80 78
 
81 79
 
82 80
 "========"
... ...
@@ -97,6 +95,8 @@ if isdirectory(expand("~/.vim/bundle/Vundle.vim"))
97 95
     Plugin 'gmarik/Vundle.vim'
98 96
 
99 97
     Plugin 'scrooloose/nerdtree'
98
+    Plugin 'chrisbra/Recover.vim'
99
+    Plugin 'tpope/vim-commentary'
100 100
     " All of your Plugins must be added before the following line
101 101
     call vundle#end()            " required
102 102
     filetype plugin indent on    " and turn it back on!
... ...
@@ -117,7 +117,6 @@ else
117 117
 endif
118 118
 
119 119
 
120
-
121 120
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
122 121
 " => VIM user interface
123 122
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
... ...
@@ -183,13 +182,7 @@ syntax enable
183 182
 colorscheme desert
184 183
 set background=dark
185 184
 
186
-" Set extra options when running in GUI mode
187
-if has("gui_running")
188
-    set guioptions-=T
189
-    set guioptions+=e
190
-    set t_Co=256
191
-    set guitablabel=%M\ %t
192
-endif
185
+set t_Co=256
193 186
 
194 187
 " Set utf8 as standard encoding and en_US as the standard language
195 188
 set encoding=utf8
... ...
@@ -201,10 +194,41 @@ set ffs=unix,dos,mac
201 194
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
202 195
 " => Files, backups and undo
203 196
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
197
+" Backup
198
+let backupdir=$HOME . "/.vim/.backup//"
199
+if !isdirectory(backupdir)
200
+    call mkdir(backupdir, "p", 0700)
201
+endif
202
+let &backupdir=backupdir
204 203
 
205
-set undodir=~/.vim/.undo//
206
-set backupdir=~/.vim/.backup//
207
-set directory=~/.vim/.swp//
204
+" Undo
205
+let dir=$HOME . "/.vim/.undo//"
206
+let &undodir=dir
207
+if !isdirectory(dir)
208
+    call mkdir(dir, "p", 0700)
209
+endif
210
+set undofile                " Save undos after file closes
211
+set undolevels=1000         " How many undos
212
+set undoreload=10000        " Number of lines to save for undo
213
+
214
+" Swap
215
+let dir=$HOME . "/.vim/.swp//"
216
+let &directory=dir
217
+if !isdirectory(dir)
218
+    call mkdir(dir, "p", 0700)
219
+endif
220
+
221
+" Specific set if running sudo
222
+let output =  system("test $EUID -eq 0")
223
+if v:shell_error == 0
224
+    set nobackup
225
+    set noundofile
226
+    set noswapfile
227
+endif
228
+
229
+" Clean variables
230
+unlet dir
231
+unlet output
208 232
 
209 233
 
210 234
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
... ...
@@ -315,12 +339,13 @@ nmap <M-k> mz:m-2<cr>`z
315 339
 vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
316 340
 vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
317 341
 
318
-if has("mac") || has("macunix")
319
-  nmap <D-j> <M-j>
320
-  nmap <D-k> <M-k>
321
-  vmap <D-j> <M-j>
322
-  vmap <D-k> <M-k>
323
-endif
342
+" Duplicate lines using Ctrl+D
343
+vmap <C-d> :'<,'>t'><cr>'[O<Esc>
344
+nmap <C-d> yyp
345
+
346
+" Search and replace
347
+nnoremap <leader>h y:<C-U>let replacement = input('Enter replacement string: ') <bar> %s//\=replacement/gc<CR>
348
+xnoremap <leader>h y:<C-U>let replacement = input('Enter replacement string: ') <bar> %s/<C-R>"/\=replacement/gc<CR>
324 349
 
325 350
 " Delete trailing white space on save, useful for Python and CoffeeScript ;)
326 351
 func! DeleteTrailingWS()
... ...
@@ -377,7 +402,6 @@ map <leader>sa zg
377 402
 map <leader>s? z=
378 403
 
379 404
 
380
-
381 405
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
382 406
 " => Misc
383 407
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
... ...
@@ -393,12 +417,11 @@ map <leader>pp :setlocal paste!<cr>
393 417
 " Toggle hilight search on or or using F8 (source: http://www.developpez.net/forums/d8477/systemes/linux/applications/enlever-surbrillance-lors-recherche-vi/)
394 418
 nnoremap <f8> :set hlsearch!\|set hlsearch?<cr>
395 419
 
396
-" visually select block of text to comment (modified from http://vim.wikia.com/wiki/Commenting_out_a_range_of_lines)
397
-vmap <C-M>  :s/^/#/<CR>:noh<CR>
398
-
399
-" uncomment visually selected text, with Ctrl-N,N(modified from http://vim.wikia.com/wiki/Commenting_out_a_range_of_lines)
400
-vmap <C-N> :s/^#//<CR>:noh<CR>
420
+" Clear search
421
+map <leader>c :let @/=""<CR>
401 422
 
423
+" (Un)comment block of text (depend on commentary-vim plugin)
424
+vmap <C-M> gc
402 425
 
403 426
 
404 427
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Browse code

vimrc - v0.4 - Add backup system

Fred authored on20/11/2019 13:08:54
Showing1 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2 2
 " Versions
3 3
 "
4
+" v0.4 - 2019-11-20: Backup, undo and swap added
4 5
 " v0.3 - 2019-07-07: Vundle installation detection
5 6
 " v0.2 - 2015-02-19: Vundle added
6 7
 " v0.1 - 2014-10-19: variable for screen integration set / commands for (un)commenting block added / no backup behavior
... ...
@@ -200,10 +201,10 @@ set ffs=unix,dos,mac
200 201
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
201 202
 " => Files, backups and undo
202 203
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
203
-" Turn backup off, since most stuff is in SVN, git et.c anyway...
204
-set nobackup
205
-set nowb
206
-set noswapfile
204
+
205
+set undodir=~/.vim/.undo//
206
+set backupdir=~/.vim/.backup//
207
+set directory=~/.vim/.swp//
207 208
 
208 209
 
209 210
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Browse code

vimrc - v0.3 - Detect Vundle

Fred authored on07/07/2019 17:46:01
Showing1 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2 2
 " Versions
3 3
 "
4
+" v0.3 - 2019-07-07: Vundle installation detection
4 5
 " v0.2 - 2015-02-19: Vundle added
5 6
 " v0.1 - 2014-10-19: variable for screen integration set / commands for (un)commenting block added / no backup behavior
6 7
 " v0.0 - 2012-06-09: current vimrc fetch from the Internet
... ...
@@ -81,34 +82,38 @@ set t_Co=256
81 82
 " Vundle "
82 83
 "========"
83 84
 
84
-set nocompatible              " be iMproved, required
85
-filetype off                  " required
86
-
87
-" set the runtime path to include Vundle and initialize
88
-set rtp+=~/.vim/bundle/Vundle.vim
89
-call vundle#begin()
90
-" alternatively, pass a path where Vundle should install plugins
91
-"call vundle#begin('~/some/path/here')
92
-
93
-" let Vundle manage Vundle, required
94
-Plugin 'gmarik/Vundle.vim'
95
-
96
-Plugin 'scrooloose/nerdtree'
97
-" All of your Plugins must be added before the following line
98
-call vundle#end()            " required
99
-filetype plugin indent on " and turn it back on!
100
-
101
-" To ignore plugin indent changes, instead use:
102
-"filetype plugin on
103
-"
104
-" Brief help
105
-" :PluginList       - lists configured plugins
106
-" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
107
-" :PluginSearch foo - searches for foo; append `!` to refresh local cache
108
-" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
109
-"
110
-" see :h vundle for more details or wiki for FAQ
111
-" Put your non-Plugin stuff after this line
85
+if isdirectory(expand("~/.vim/bundle/Vundle.vim"))
86
+    set nocompatible              " be iMproved, required
87
+    filetype off                  " required
88
+
89
+    " set the runtime path to include Vundle and initialize
90
+    set rtp+=~/.vim/bundle/Vundle.vim
91
+    call vundle#begin()
92
+    " alternatively, pass a path where Vundle should install plugins
93
+    "call vundle#begin('~/some/path/here')
94
+
95
+    " let Vundle manage Vundle, required
96
+    Plugin 'gmarik/Vundle.vim'
97
+
98
+    Plugin 'scrooloose/nerdtree'
99
+    " All of your Plugins must be added before the following line
100
+    call vundle#end()            " required
101
+    filetype plugin indent on    " and turn it back on!
102
+
103
+    " To ignore plugin indent changes, instead use:
104
+    "filetype plugin on
105
+    "
106
+    " Brief help
107
+    " :PluginList       - lists configured plugins
108
+    " :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
109
+    " :PluginSearch foo - searches for foo; append `!` to refresh local cache
110
+    " :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
111
+    "
112
+    " see :h vundle for more details or wiki for FAQ
113
+    " Put your non-Plugin stuff after this line
114
+else
115
+    echom "Vundle not installed"
116
+endif
112 117
 
113 118
 
114 119
 
Browse code

vimrc - v0.2 - Add Vundle

Fred authored on19/02/2015 11:03:13
Showing1 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2 2
 " Versions
3 3
 "
4
+" v0.2 - 2015-02-19: Vundle added
4 5
 " v0.1 - 2014-10-19: variable for screen integration set / commands for (un)commenting block added / no backup behavior
5 6
 " v0.0 - 2012-06-09: current vimrc fetch from the Internet
6 7
 " 
... ...
@@ -76,6 +77,40 @@ let g:mapleader = ","
76 77
 set t_Co=256
77 78
 
78 79
 
80
+"========"
81
+" Vundle "
82
+"========"
83
+
84
+set nocompatible              " be iMproved, required
85
+filetype off                  " required
86
+
87
+" set the runtime path to include Vundle and initialize
88
+set rtp+=~/.vim/bundle/Vundle.vim
89
+call vundle#begin()
90
+" alternatively, pass a path where Vundle should install plugins
91
+"call vundle#begin('~/some/path/here')
92
+
93
+" let Vundle manage Vundle, required
94
+Plugin 'gmarik/Vundle.vim'
95
+
96
+Plugin 'scrooloose/nerdtree'
97
+" All of your Plugins must be added before the following line
98
+call vundle#end()            " required
99
+filetype plugin indent on " and turn it back on!
100
+
101
+" To ignore plugin indent changes, instead use:
102
+"filetype plugin on
103
+"
104
+" Brief help
105
+" :PluginList       - lists configured plugins
106
+" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
107
+" :PluginSearch foo - searches for foo; append `!` to refresh local cache
108
+" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
109
+"
110
+" see :h vundle for more details or wiki for FAQ
111
+" Put your non-Plugin stuff after this line
112
+
113
+
79 114
 
80 115
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
81 116
 " => VIM user interface
... ...
@@ -359,6 +394,7 @@ vmap <C-M>  :s/^/#/<CR>:noh<CR>
359 394
 vmap <C-N> :s/^#//<CR>:noh<CR>
360 395
 
361 396
 
397
+
362 398
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
363 399
 " => Helper functions
364 400
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Browse code

vimrc - v0.1 - Improve commenting and screen behavior

Fred authored on19/10/2014 18:02:19
Showing1 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2 2
 " Versions
3 3
 "
4
+" v0.1 - 2014-10-19: variable for screen integration set / commands for (un)commenting block added / no backup behavior
4 5
 " v0.0 - 2012-06-09: current vimrc fetch from the Internet
5 6
 " 
6 7
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
... ...
@@ -69,7 +70,11 @@ let mapleader = ","
69 70
 let g:mapleader = ","
70 71
 
71 72
 " Fast saving
72
-nmap <leader>w :w!<cr>
73
+"nmap <leader>w :w!<cr>
74
+
75
+" Set 256 colors
76
+set t_Co=256
77
+
73 78
 
74 79
 
75 80
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
... ...
@@ -156,7 +161,7 @@ set ffs=unix,dos,mac
156 161
 " => Files, backups and undo
157 162
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
158 163
 " Turn backup off, since most stuff is in SVN, git et.c anyway...
159
-"set nobackup
164
+set nobackup
160 165
 set nowb
161 166
 set noswapfile
162 167
 
... ...
@@ -331,6 +336,7 @@ map <leader>sa zg
331 336
 map <leader>s? z=
332 337
 
333 338
 
339
+
334 340
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
335 341
 " => Misc
336 342
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
... ...
@@ -343,6 +349,14 @@ map <leader>q :e ~/buffer<cr>
343 349
 " Toggle paste mode on and off
344 350
 map <leader>pp :setlocal paste!<cr>
345 351
 
352
+" Toggle hilight search on or or using F8 (source: http://www.developpez.net/forums/d8477/systemes/linux/applications/enlever-surbrillance-lors-recherche-vi/)
353
+nnoremap <f8> :set hlsearch!\|set hlsearch?<cr>
354
+
355
+" visually select block of text to comment (modified from http://vim.wikia.com/wiki/Commenting_out_a_range_of_lines)
356
+vmap <C-M>  :s/^/#/<CR>:noh<CR>
357
+
358
+" uncomment visually selected text, with Ctrl-N,N(modified from http://vim.wikia.com/wiki/Commenting_out_a_range_of_lines)
359
+vmap <C-N> :s/^#//<CR>:noh<CR>
346 360
 
347 361
 
348 362
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
... ...
@@ -404,5 +418,3 @@ function! <SID>BufcloseCloseIt()
404 418
      execute("bdelete! ".l:currentBufNum)
405 419
    endif
406 420
 endfunction
407
-
408
-
Browse code

vimrc - v0.0 - see Versions section for details

Fred authored on09/06/2012 12:14:18
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,408 @@
1
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2
+" Versions
3
+"
4
+" v0.0 - 2012-06-09: current vimrc fetch from the Internet
5
+" 
6
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
7
+
8
+
9
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
10
+" Original header
11
+"
12
+" Maintainer: 
13
+"       Amir Salihefendic
14
+"       http://amix.dk - amix@amix.dk
15
+"
16
+" Version: 
17
+"       5.0 - 29/05/12 15:43:36
18
+"
19
+" Blog_post: 
20
+"       http://amix.dk/blog/post/19691#The-ultimate-Vim-configuration-on-Github
21
+"
22
+" Awesome_version:
23
+"       Get this config, nice color schemes and lots of plugins!
24
+"
25
+"       Install the awesome version from:
26
+"
27
+"           https://github.com/amix/vimrc
28
+"
29
+" Syntax_highlighted:
30
+"       http://amix.dk/vim/vimrc.html
31
+"
32
+" Raw_version: 
33
+"       http://amix.dk/vim/vimrc.txt
34
+"
35
+" Sections:
36
+"    -> General
37
+"    -> VIM user interface
38
+"    -> Colors and Fonts
39
+"    -> Files and backups
40
+"    -> Text, tab and indent related
41
+"    -> Visual mode related
42
+"    -> Moving around, tabs and buffers
43
+"    -> Status line
44
+"    -> Editing mappings
45
+"    -> vimgrep searching and cope displaying
46
+"    -> Spell checking
47
+"    -> Misc
48
+"    -> Helper functions
49
+"
50
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
51
+
52
+
53
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
54
+" => General
55
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
56
+" Sets how many lines of history VIM has to remember
57
+set history=700
58
+
59
+" Enable filetype plugins
60
+filetype plugin on
61
+filetype indent on
62
+
63
+" Set to auto read when a file is changed from the outside
64
+set autoread
65
+
66
+" With a map leader it's possible to do extra key combinations
67
+" like <leader>w saves the current file
68
+let mapleader = ","
69
+let g:mapleader = ","
70
+
71
+" Fast saving
72
+nmap <leader>w :w!<cr>
73
+
74
+
75
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
76
+" => VIM user interface
77
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
78
+" Set 7 lines to the cursor - when moving vertically using j/k
79
+set so=7
80
+
81
+" Turn on the WiLd menu
82
+set wildmenu
83
+
84
+" Ignore compiled files
85
+set wildignore=*.o,*~,*.pyc
86
+
87
+"Always show current position
88
+set ruler
89
+
90
+" Height of the command bar
91
+set cmdheight=2
92
+
93
+" A buffer becomes hidden when it is abandoned
94
+set hid
95
+
96
+" Configure backspace so it acts as it should act
97
+set backspace=eol,start,indent
98
+set whichwrap+=<,>,h,l
99
+
100
+" Ignore case when searching
101
+set ignorecase
102
+
103
+" When searching try to be smart about cases 
104
+set smartcase
105
+
106
+" Highlight search results
107
+set hlsearch
108
+
109
+" Makes search act like search in modern browsers
110
+set incsearch
111
+
112
+" Don't redraw while executing macros (good performance config)
113
+set lazyredraw
114
+
115
+" For regular expressions turn magic on
116
+set magic
117
+
118
+" Show matching brackets when text indicator is over them
119
+set showmatch
120
+
121
+" How many tenths of a second to blink when matching brackets
122
+set mat=2
123
+
124
+" No annoying sound on errors
125
+set noerrorbells
126
+set novisualbell
127
+set t_vb=
128
+set tm=500
129
+
130
+
131
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
132
+" => Colors and Fonts
133
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
134
+" Enable syntax highlighting
135
+syntax enable
136
+
137
+colorscheme desert
138
+set background=dark
139
+
140
+" Set extra options when running in GUI mode
141
+if has("gui_running")
142
+    set guioptions-=T
143
+    set guioptions+=e
144
+    set t_Co=256
145
+    set guitablabel=%M\ %t
146
+endif
147
+
148
+" Set utf8 as standard encoding and en_US as the standard language
149
+set encoding=utf8
150
+
151
+" Use Unix as the standard file type
152
+set ffs=unix,dos,mac
153
+
154
+
155
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
156
+" => Files, backups and undo
157
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
158
+" Turn backup off, since most stuff is in SVN, git et.c anyway...
159
+"set nobackup
160
+set nowb
161
+set noswapfile
162
+
163
+
164
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
165
+" => Text, tab and indent related
166
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
167
+" Use spaces instead of tabs
168
+set expandtab
169
+
170
+" Be smart when using tabs ;)
171
+set smarttab
172
+
173
+" 1 tab == 4 spaces
174
+set shiftwidth=4
175
+set tabstop=4
176
+
177
+" Linebreak on 500 characters
178
+set lbr
179
+set tw=500
180
+
181
+set ai "Auto indent
182
+set si "Smart indent
183
+set wrap "Wrap lines
184
+
185
+
186
+""""""""""""""""""""""""""""""
187
+" => Visual mode related
188
+""""""""""""""""""""""""""""""
189
+" Visual mode pressing * or # searches for the current selection
190
+" Super useful! From an idea by Michael Naumann
191
+vnoremap <silent> * :call VisualSelection('f')<CR>
192
+vnoremap <silent> # :call VisualSelection('b')<CR>
193
+
194
+
195
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
196
+" => Moving around, tabs, windows and buffers
197
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
198
+" Treat long lines as break lines (useful when moving around in them)
199
+map j gj
200
+map k gk
201
+
202
+" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
203
+map <space> /
204
+map <c-space> ?
205
+
206
+" Disable highlight when <leader><cr> is pressed
207
+map <silent> <leader><cr> :noh<cr>
208
+
209
+" Smart way to move between windows
210
+map <C-j> <C-W>j
211
+map <C-k> <C-W>k
212
+map <C-h> <C-W>h
213
+map <C-l> <C-W>l
214
+
215
+" Close the current buffer
216
+map <leader>bd :Bclose<cr>
217
+
218
+" Close all the buffers
219
+map <leader>ba :1,1000 bd!<cr>
220
+
221
+" Useful mappings for managing tabs
222
+map <leader>tn :tabnew<cr>
223
+map <leader>to :tabonly<cr>
224
+map <leader>tc :tabclose<cr>
225
+map <leader>tm :tabmove
226
+
227
+" Opens a new tab with the current buffer's path
228
+" Super useful when editing files in the same directory
229
+map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
230
+
231
+" Switch CWD to the directory of the open buffer
232
+map <leader>cd :cd %:p:h<cr>:pwd<cr>
233
+
234
+" Specify the behavior when switching between buffers 
235
+try
236
+  set switchbuf=useopen,usetab,newtab
237
+  set stal=2
238
+catch
239
+endtry
240
+
241
+" Return to last edit position when opening files (You want this!)
242
+autocmd BufReadPost *
243
+     \ if line("'\"") > 0 && line("'\"") <= line("$") |
244
+     \   exe "normal! g`\"" |
245
+     \ endif
246
+" Remember info about open buffers on close
247
+set viminfo^=%
248
+
249
+
250
+""""""""""""""""""""""""""""""
251
+" => Status line
252
+""""""""""""""""""""""""""""""
253
+" Always show the status line
254
+set laststatus=2
255
+
256
+" Format the status line
257
+set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ \ Col.:\ %c
258
+
259
+
260
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
261
+" => Editing mappings
262
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
263
+" Remap VIM 0 to first non-blank character
264
+map 0 ^
265
+
266
+" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
267
+nmap <M-j> mz:m+<cr>`z
268
+nmap <M-k> mz:m-2<cr>`z
269
+vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
270
+vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
271
+
272
+if has("mac") || has("macunix")
273
+  nmap <D-j> <M-j>
274
+  nmap <D-k> <M-k>
275
+  vmap <D-j> <M-j>
276
+  vmap <D-k> <M-k>
277
+endif
278
+
279
+" Delete trailing white space on save, useful for Python and CoffeeScript ;)
280
+func! DeleteTrailingWS()
281
+  exe "normal mz"
282
+  %s/\s\+$//ge
283
+  exe "normal `z"
284
+endfunc
285
+autocmd BufWrite *.py :call DeleteTrailingWS()
286
+autocmd BufWrite *.coffee :call DeleteTrailingWS()
287
+
288
+
289
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
290
+" => vimgrep searching and cope displaying
291
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
292
+" When you press gv you vimgrep after the selected text
293
+vnoremap <silent> gv :call VisualSelection('gv')<CR>
294
+
295
+" Open vimgrep and put the cursor in the right position
296
+map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
297
+
298
+" Vimgreps in the current file
299
+map <leader><space> :vimgrep // <C-R>%<C-A><right><right><right><right><right><right><right><right><right>
300
+
301
+" When you press <leader>r you can search and replace the selected text
302
+vnoremap <silent> <leader>r :call VisualSelection('replace')<CR>
303
+
304
+" Do :help cope if you are unsure what cope is. It's super useful!
305
+"
306
+" When you search with vimgrep, display your results in cope by doing:
307
+"   <leader>cc
308
+"
309
+" To go to the next search result do:
310
+"   <leader>n
311
+"
312
+" To go to the previous search results do:
313
+"   <leader>p
314
+"
315
+map <leader>cc :botright cope<cr>
316
+map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
317
+map <leader>n :cn<cr>
318
+map <leader>p :cp<cr>
319
+
320
+
321
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
322
+" => Spell checking
323
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
324
+" Pressing ,ss will toggle and untoggle spell checking
325
+map <leader>ss :setlocal spell!<cr>
326
+
327
+" Shortcuts using <leader>
328
+map <leader>sn ]s
329
+map <leader>sp [s
330
+map <leader>sa zg
331
+map <leader>s? z=
332
+
333
+
334
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
335
+" => Misc
336
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
337
+" Remove the Windows ^M - when the encodings gets messed up
338
+noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
339
+
340
+" Quickly open a buffer for scripbble
341
+map <leader>q :e ~/buffer<cr>
342
+
343
+" Toggle paste mode on and off
344
+map <leader>pp :setlocal paste!<cr>
345
+
346
+
347
+
348
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
349
+" => Helper functions
350
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
351
+function! CmdLine(str)
352
+    exe "menu Foo.Bar :" . a:str
353
+    emenu Foo.Bar
354
+    unmenu Foo
355
+endfunction
356
+
357
+function! VisualSelection(direction) range
358
+    let l:saved_reg = @"
359
+    execute "normal! vgvy"
360
+
361
+    let l:pattern = escape(@", '\\/.*$^~[]')
362
+    let l:pattern = substitute(l:pattern, "\n$", "", "")
363
+
364
+    if a:direction == 'b'
365
+        execute "normal ?" . l:pattern . "^M"
366
+    elseif a:direction == 'gv'
367
+        call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
368
+    elseif a:direction == 'replace'
369
+        call CmdLine("%s" . '/'. l:pattern . '/')
370
+    elseif a:direction == 'f'
371
+        execute "normal /" . l:pattern . "^M"
372
+    endif
373
+
374
+    let @/ = l:pattern
375
+    let @" = l:saved_reg
376
+endfunction
377
+
378
+
379
+" Returns true if paste mode is enabled
380
+function! HasPaste()
381
+    if &paste
382
+        return 'PASTE MODE  '
383
+    en
384
+    return ''
385
+endfunction
386
+
387
+" Don't close window, when deleting a buffer
388
+command! Bclose call <SID>BufcloseCloseIt()
389
+function! <SID>BufcloseCloseIt()
390
+   let l:currentBufNum = bufnr("%")
391
+   let l:alternateBufNum = bufnr("#")
392
+
393
+   if buflisted(l:alternateBufNum)
394
+     buffer #
395
+   else
396
+     bnext
397
+   endif
398
+
399
+   if bufnr("%") == l:currentBufNum
400
+     new
401
+   endif
402
+
403
+   if buflisted(l:currentBufNum)
404
+     execute("bdelete! ".l:currentBufNum)
405
+   endif
406
+endfunction
407
+
408
+