]> git.rmz.io Git - dotfiles.git/blob - vim/vimrc
9284bf50103126b783d1ce8fd4a3c328c124fcb9
[dotfiles.git] / vim / vimrc
1 " My vimrc.
2 "
3 " Author: Samir Benmendil <samir.benmendil[at]gmail[dot]com>
4 "
5
6 " plugins {{{1
7 filetype off
8 set runtimepath& " reset rtp
9 " remove all autocommands
10 autocmd!
11
12 set runtimepath+=$XDG_DATA_HOME/vim/vundle
13 call vundle#rc('$XDG_DATA_HOME/vim')
14
15 Plugin 'gmarik/vundle'
16
17 Plugin 'airblade/vim-gitgutter'
18 Plugin 'bling/vim-airline'
19 Plugin 'derekwyatt/vim-fswitch'
20 Plugin 'elzr/vim-json'
21 Plugin 'firef0x/pkgbuild.vim'
22 Plugin 'junegunn/vim-easy-align'
23 " Plugin 'kien/ctrlp.vim'
24 " Plugin 'klen/python-mode'
25 Plugin 'wilywampa/python-mode'
26 Plugin 'kshenoy/vim-signature'
27 Plugin 'majutsushi/tagbar'
28 Plugin 'raimondi/delimitmate'
29 Plugin 'rking/ag.vim'
30 Plugin 'scrooloose/nerdtree'
31 Plugin 'scrooloose/syntastic'
32 Plugin 'sjl/gundo.vim'
33 Plugin 'tomtom/tcomment_vim'
34 Plugin 'tpope/vim-endwise'
35 Plugin 'tpope/vim-fugitive'
36 Plugin 'tpope/vim-repeat'
37 Plugin 'tpope/vim-surround'
38 Plugin 'tpope/vim-unimpaired'
39 Plugin 'valloric/youcompleteme'
40 Plugin 'vim-scripts/yankring.vim'
41
42 " snippets
43 Plugin 'sirver/ultisnips'
44 Plugin 'honza/vim-snippets'
45
46 " text objects
47 Plugin 'kana/vim-textobj-user'
48 Plugin 'julian/vim-textobj-variable-segment'
49 Plugin 'sgur/vim-textobj-parameter'
50
51 " ros
52 Plugin 'ompugao/ros.vim'
53 Plugin 'ompugao/ctrlp-ros'
54
55 " seems to have problems right now... may be add later?
56 " Plugin 'jalcine/cmake.vim'
57 " Plugin 'powerman/vim-plugin-viewdoc'
58
59 " find an alternative (latex-box? Automatic Latex Plugin?)
60 Plugin 'http://git.code.sf.net/p/vim-latex/vim-latex'
61 " Plugin 'lokaltog/vim-easymotion'
62 Plugin 'justinmk/vim-sneak'
63 Plugin 'chrisbra/checkattach'
64 Plugin 'nathanaelkane/vim-indent-guides'
65 Plugin 'alx741/vinfo'
66 Plugin 'shougo/unite.vim'
67
68 " remove entries first
69 set runtimepath -=$HOME/.vim
70 set runtimepath -=$HOME/.vim/after
71 set runtimepath -=$XDG_CONFIG_HOME/vim
72 set runtimepath -=$XDG_CONFIG_HOME/vim/after
73 " then prepend and append them
74 set runtimepath ^=$XDG_CONFIG_HOME/vim
75 set runtimepath +=$XDG_CONFIG_HOME/vim/after
76
77 filetype plugin indent on
78
79 " colorscheme {{{1
80 syntax on
81 colorscheme badwolf
82
83 " options {{{1
84 " moving around, searching and patterns {{{2
85 set incsearch " show match for partly typed search command
86 set ignorecase " ignore case when using a search pattern
87 set smartcase " override 'ignorecase' when pattern has upper case characters
88 set hlsearch " highlight all matches for the last used search pattern
89
90 set nostartofline " don't move the cursor to the first non-blank char of a line
91 set path=.,include/,../include/,/usr/include/c++/*,/opt/ros/hydro/include
92
93 " displaying text {{{2
94 set scrolloff=5 " number of screen lines to show around the cursor
95 set nowrap " long lines wrap
96 set linebreak " wrap long lines at a character in 'breakat'
97 set showbreak=↪ " show these chars for wrapped lines
98
99 set lazyredraw " don't redraw while executing macros
100
101 set list " show chars defined in 'listchars'
102 set listchars=tab:▸\ " list of strings used for list mode
103 set listchars+=extends:❯,precedes:❮
104 " Only shown when not in insert mode
105 augroup trailing
106 au!
107 au InsertEnter * :set listchars-=trail:·
108 au InsertLeave * :set listchars+=trail:·
109 augroup END
110
111 set sidescroll=1 " number of collumns to scroll
112 set sidescrolloff=1 " don't scroll over the listchars
113
114 set fillchars=diff:⣿,vert:│
115
116 set nonumber " show the line number for each line
117 set norelativenumber " show the relative line number for each line
118
119 " syntax, highlighting and spelling {{{2
120 set synmaxcol=800 " don't highlight long lines
121
122 set dictionary=spell " list of dictionary files for keyword completion
123
124 set colorcolumn=+1
125
126 " multiple windows {{{2
127 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
128
129 set previewheight=20 " default height for the preview window
130
131 set hidden
132
133 " set splitbelow " a new window is put below of the current one
134 set splitright " a new window is put right of the current one
135
136 " terminal {{{2
137 set ttyfast
138
139 " using the mouse {{{2
140 set mouse=rnv " list of flags for using the mouse
141 set ttymouse=xterm " type of mouse
142
143 " messages and info {{{2
144 set showcmd " Show (partial) command in status line.
145 set ruler " show the cursor position all the time
146 set confirm " Ask what to do when closing unsaved documents
147 set shortmess=filnxtoOI " don't show intro message
148
149 " editing text {{{2
150 set backspace=indent,eol,start " allow backspacing over everything in insert mode
151
152 set showmatch " Show matching brackets.
153
154 set nojoinspaces " don't use two spaces after '.' when joining a line
155 set formatoptions=jcrnql
156
157 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
158
159 set complete=.,w,b,u,t
160 " whether to use a popup menu for Insert mode completion
161 set completeopt=longest,menuone,preview
162
163 " tabs and indent {{{2
164 set shiftwidth=4 " number of spaces used for each step of (auto)indent
165 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
166 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
167 set shiftround " round to 'shiftwidth' for "<<" and ">>"
168 set expandtab " expand <Tab> to spaces in Insert mode
169 set autoindent
170
171 set pastetoggle=<F11> " key sequence to toggle paste mode
172
173 " folding {{{2
174 set foldmethod=marker " folding type
175 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
176
177 " save and restore folds
178 set viewoptions=cursor " only save cursor position
179
180 " diff mode {{{2
181 set diffopt=filler,vertical
182
183 " reading and writing files {{{2
184 set modeline " read modelines
185 set modelines=2 " only check first/last 2 lines
186
187 set writebackup " write a backup file before overwriting a file
188 set backup " keep a backup after owerwriting a file
189 set backupdir=$XDG_CACHE_HOME/vim/backup//
190
191 set backupskip+=.netrc " skip netrc
192 set backupskip+=/dev/shm/pass* " skip passwordstore files
193
194 set undofile " persistent undo history
195 set undodir=$XDG_CACHE_HOME/vim/undo//
196
197 augroup undoskip
198 au!
199 au BufWritePre .netrc setlocal noundofile
200 au BufWritePre /dev/shm/pass* setlocal noundofile
201 au BufWritePre /tmp/* setlocal noundofile
202 augroup END
203
204 set autowrite " automatically write a file when leaving a modified buffer
205 set autoread " automatically read a file that has been modified
206
207 " the swap file {{{2
208 set noswapfile
209 set directory=$XDG_CACHE_HOME/vim/swap//
210
211 " command line editing {{{2
212 set history=5000 " how many command lines are remembered
213 set wildmenu " command-line completion shows a list of matches
214 set wildmode=longest:full,full " specifies how command line completion works
215
216 set wildignore+=.hg,.git,.svn " Version control
217 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
218 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
219 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
220 set wildignore+=*.spl " compiled spelling word lists
221 set wildignore+=*.sw? " Vim swap files
222 set wildignore+=*.luac " Lua byte code
223 set wildignore+=*.pyc " Python byte code
224 set wildignore+=*.orig " Merge resolution files
225
226 " various {{{2
227 set virtualedit=block " let cursor move past last char in <C-V> mode
228 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
229
230 set viewdir=$XDG_CACHE_HOME/vim/view//
231
232 " autocmds {{{1
233 " Resize splits when the window is resized {{{2
234 augroup resize
235 au!
236 autocmd VimResized * :wincmd =
237 augroup END
238
239 " Only show cursorline in the current window and in normal mode {{{2
240 augroup cline
241 au!
242 au WinLeave,InsertEnter * set nocursorline
243 au WinEnter,InsertLeave * set cursorline
244 augroup END
245
246 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
247 augroup ft_stdin
248 au!
249 au StdinReadPost * :set buftype=nofile
250 augroup END
251
252 " Jump to last known cursor position {{{2
253 augroup cursor_pos
254 au!
255 " blacklist certain filetype
256 let blacklist = ['gitcommit']
257 autocmd BufReadPost *
258 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
259 \ exe "normal! g`\"" |
260 \ endif
261 augroup END
262
263 " bindings {{{1
264
265 " allow both <space> and / to be <leader>
266 map <space> <leader>
267
268 " make
269 nnoremap <leader>r :make<cr>
270 nnoremap <leader><cr> :make<cr>
271
272 " unhighlight search
273 nnoremap <silent> <Leader>/ :silent nohl<CR>
274
275 " Tabs
276 nnoremap <leader>[ :tabprev<cr>
277 nnoremap <leader>] :tabnext<cr>
278
279 " paste from selection
280 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
281 " paste from clipboard
282 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
283
284 " Clean trailing whitespace
285 nnoremap <silent> <leader>ww m':%s/\s\+$//<cr>:let @/=''<cr>``zz
286
287 " Source
288 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
289 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
290
291 " jump to last cursor position
292 noremap ' `
293
294 " Select (charwise) the contents of the current line, excluding indentation.
295 nnoremap vv ^vg_
296
297 " Unfuck my screen
298 nnoremap U :syntax sync fromstart<cr>:AirlineRefresh<cr>:redraw!<cr>
299
300 " Ranger
301 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
302 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
303
304 " Use sane regexes.
305 nnoremap / /\v
306 vnoremap / /\v
307 cnoremap s/ s/\v
308
309 " display the number of matches for the last search
310 nmap <Leader># :%s:<C-R>/::gn<CR>
311
312 " center cursor after search and open folds
313 nnoremap n nzzzv
314 nnoremap N Nzzzv
315
316 " same when jumping around
317 nnoremap g; g;zzzv
318 nnoremap g, g,zzzv
319 nnoremap <c-o> <c-o>zzzv
320
321 " Not using the default mappings of 'To line from top/bottom'
322 noremap H ^
323 noremap L $
324 vnoremap H ^
325 vnoremap L g_
326
327 " Heresy, emacs insert bindings
328 inoremap <c-a> <esc>I
329 inoremap <c-e> <esc>A
330 cnoremap <c-a> <home>
331 cnoremap <c-e> <end>
332
333 " proper movement when lines are wrapped
334 noremap <expr> j (v:count == 0 ? 'gj' : 'j')
335 noremap <expr> k (v:count == 0 ? 'gk' : 'k')
336
337 " disable arrows
338 noremap <Up> <NOP>
339 noremap <Down> <NOP>
340 noremap <Left> <NOP>
341 noremap <Right> <NOP>
342 inoremap <Up> <NOP>
343 inoremap <Down> <NOP>
344 inoremap <Left> <NOP>
345 inoremap <Right> <NOP>
346 cnoremap <Up> <NOP>
347 cnoremap <Down> <NOP>
348 cnoremap <Left> <NOP>
349 cnoremap <Right> <NOP>
350 cnoremap <C-K> <Up>
351 cnoremap <C-J> <Down>
352 cnoremap <C-H> <Left>
353 cnoremap <C-L> <Right>
354
355 " close all folds open fold in cursor
356 nnoremap zx zMzxzt
357
358 map <F1> :ls<CR>:b<space>
359
360 nnoremap <C-L> <C-W>w
361 nnoremap <C-H> <C-W>W
362
363 "xterm mouse with middleclick paste
364 nnoremap <MiddleMouse> i<MiddleMouse>
365 vnoremap <MiddleMouse> s<MiddleMouse>
366
367 " fix legacy vi inconsistency
368 map Y y$
369
370 " allow repeat operator on visual
371 vnoremap . :normal .<CR>
372
373 " add line without changing position or leaving mode
374 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
375 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
376
377 " Don't use Ex mode, use Q for formatting
378 map Q gq
379
380 " break undo sequence before removing word
381 inoremap <C-W> <C-G>u<C-W>
382
383 nmap <Leader>b :set expandtab tabstop=4 shiftwidth=4 softtabstop=4<CR>
384 nmap <Leader>B :set expandtab tabstop=8 shiftwidth=8 softtabstop=4<CR>
385 nmap <Leader>M :set noexpandtab tabstop=8 softtabstop=4 shiftwidth=4<CR>
386 nmap <Leader>m :set expandtab tabstop=2 shiftwidth=2 softtabstop=2<CR>
387
388 " space will toggle current fold in normal mode
389 nnoremap <leader><Space> za
390 " create folds around visual selection
391 vnoremap <leader><Space> zf
392
393 autocmd BufWinLeave *.* mkview
394 autocmd BufWinEnter *.* silent loadview
395
396 " save with sudo
397 cnoremap w!! w !sudo tee % > /dev/null
398
399 " uppercase previous word
400 inoremap <C-C> <Esc>gUiwgi
401
402 " plugins options {{{1
403 " ag {{{2
404 let g:AgSmartCase = 1
405 nnoremap <leader>ag yiw:Ag \12"<cr>
406 vnoremap <leader>ag y:Ag \12"<cr>
407
408 " airline {{{2
409 let g:airline#extensions#whitespace#enabled = 1
410 let g:airline#extensions#tabline#enabled = 1
411 let g:airline_powerline_fonts = 1
412
413 " checkattach {{{2
414 let g:checkattach_filebrowser = 'ranger'
415 let g:checkattach_once = 'y'
416
417 " delimitmate {{{2
418 let delimitMate_expand_cr = 2
419 let g:delimitMate_expand_space = 1
420
421 " fswitch {{{2
422 nnoremap <silent> <Leader>ff :FSHere<CR>
423 nnoremap <silent> <Leader>fl :FSRight<CR>
424 nnoremap <silent> <Leader>fh :FSLeft<CR>
425 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
426 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
427
428 " fugitive {{{2
429 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
430 " delete fugitive buffers when closed
431 autocmd BufReadPost fugitive://* set bufhidden=delete
432
433 nnoremap <silent> <leader>gs :Gstatus<CR>
434 nnoremap <silent> <leader>gd :Gdiff<CR>
435 nnoremap <silent> <leader>gc :tab Gcommit -v<CR>
436 nnoremap <silent> <leader>ga :Gwrite<cr>
437 nnoremap <silent> <leader>gb :Gblame<cr>
438
439 " Gundo {{{2
440 nnoremap <F7> :GundoToggle<CR>
441
442 " indent-guides {{{2
443 let g:indent_guides_default_mapping = 0
444 let g:indent_guides_guide_size = 1
445 nmap <silent> cog <Plug>IndentGuidesToggle
446 nmap <silent> [og <Plug>IndentGuidesEnable
447 nmap <silent> ]og <Plug>IndentGuidesDisable
448
449 " NERDTree {{{2
450 " open/close NERDTree with \e
451 nmap <Leader>e :NERDTreeToggle<CR>
452 nmap <F6> :NERDTreeToggle<CR>
453 " <space> to open files/dirs
454 let NERDTreeMapActivateNode='l'
455 " close vim if only NERDTree is open
456 autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
457
458 " python-mode {{{2
459
460 let g:pymode_rope_completion = 0
461 let g:pymode_rope = 0
462 let g:pymode_folding = 1
463 let g:pymode_lint_ignore = "E221,E266,E501"
464 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
465
466 " synastic {{{2
467 let g:syntastic_enable_highlighting = 0
468 let g:syntastic_error_symbol='E'
469 let g:syntastic_style_error_symbol='S'
470 let g:syntastic_warning_symbol='W'
471 let g:syntastic_style_warning_symbol='S'
472 let g:syntastic_always_populate_loc_list=1
473 nmap <silent> <leader>y :SyntasticCheck<cr>
474
475 if ! &diff
476 let g:syntastic_check_on_open=1
477 endif
478
479 " tagbar {{{2
480 map <F5> :TagbarToggle<cr>
481 let g:tagbar_sort = 0
482 let g:tagbar_compact = 1
483 let g:tagbar_autoshowtag = 1
484 let g:tagbar_width = 25
485 let g:tagbar_iconchars = ['+', '-']
486
487 " ultisnips {{{2
488 let g:UltiSnipsEditSplit = 'vertical'
489 let g:UltiSnipsSnippetsDir = expand("$XDG_CONFIG_HOME/vim/ultisnips")
490 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
491 let g:UltiSnipsExpandTrigger = "<tab>"
492 let g:UltiSnipsJumpForwardTrigger = "<tab>"
493 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
494
495 " UltiSnips completion function that tries to expand a snippet. If there's no
496 " snippet for expanding, it checks for completion window and if it's shown,
497 " selects first element. If there's no completion window it tries to jump to
498 " next placeholder. If there's no placeholder it just returns TAB key
499 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
500 function! g:UltiSnips_Complete()
501 call UltiSnips#ExpandSnippet()
502 if g:ulti_expand_res == 0
503 if pumvisible()
504 return "\<C-n>"
505 else
506 call UltiSnips#JumpForwards()
507 if g:ulti_jump_forwards_res == 0
508 return "\<TAB>"
509 endif
510 endif
511 endif
512 return ""
513 endfunction
514 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
515 let g:UltiSnipsListSnippets="<c-e>"
516
517 " unite {{{2
518 call unite#filters#matcher_default#use(['matcher_fuzzy'])
519 call unite#custom#profile('default', 'context', {
520 \ 'start_insert': 1,
521 \ 'winheight': 20,
522 \ 'direction': 'botright'
523 \ })
524 nnoremap [unite] <Nop>
525 nmap <leader>u [unite]
526 nnoremap <silent> [unite]f :<C-u>Unite buffer file_rec<CR>
527
528 " yankring {{{2
529 nnoremap <silent> <leader>p :YRShow<cr>
530 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
531 let g:yankring_replace_n_pkey = ''
532 let g:yankring_replace_n_nkey = ''
533
534 " map Y to y$ for the yank ring
535 function! YRRunAfterMaps()
536 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
537 endfunction
538
539 " youcompleteme {{{2
540 let g:ycm_extra_conf_globlist = ['~/src/*','/mnt/data/src/*']
541 let g:ycm_global_ycm_extra_conf = expand('$XDG_CONFIG_HOME/vim/ycm_extra_conf.py')
542 let g:ycm_extra_conf_vim_data = ['getcwd()']
543 let g:ycm_add_preview_to_completeopt = 1
544 let g:ycm_autoclose_preview_window_after_insertion = 0
545 "let g:ycm_extra_conf_vim_data = ['%:p']
546 nnoremap <leader>jd :YcmCompleter GoTo<CR>
547
548 " vim-easy-align {{{2
549 " start interactive EasyAlign in visual mode
550 vmap <Enter> <Plug>(EasyAlign)
551
552 " vim-json {{{2
553 let g:vim_json_syntax_conceal = 0
554
555 " vim-latex {{{2
556 let g:tex_flavor='latex'
557 let g:Tex_DefaultTargetFormat='pdf'
558 let g:Tex_MultipleCompileFormats='pdf'
559
560 " vim-sneak {{{2
561 let g:sneak#streak = 1
562 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
563 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
564
565 " sneaky f and t
566 nmap f <Plug>Sneak_f
567 nmap F <Plug>Sneak_F
568 xmap f <Plug>Sneak_f
569 xmap F <Plug>Sneak_F
570 omap f <Plug>Sneak_f
571 omap F <Plug>Sneak_F
572 nmap t <Plug>Sneak_t
573 nmap T <Plug>Sneak_T
574 xmap t <Plug>Sneak_t
575 xmap T <Plug>Sneak_T
576 omap t <Plug>Sneak_t
577 omap T <Plug>Sneak_T
578
579 " functions {{{1
580
581 " Convenient command to see the difference between the current buffer and the
582 " file it was loaded from, thus the changes you made.
583 " Only define it when not defined already.
584 if !exists(":DiffOrig")
585 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
586 \ | wincmd p | diffthis
587 endif
588
589 " edit configs {{{2
590 function! EditConfig(what)
591 let l:dir = split(&runtimepath,',')[0]
592 if a:what == 'vimrc'
593 let l:file = expand($MYVIMRC)
594 elseif ! isdirectory(globpath(l:dir, a:what))
595 echoe a:what." is not valid!"
596 elseif empty(&filetype)
597 echoe 'filetype is empty!'
598 else
599 let l:file = l:dir.'/'.a:what.'/'.&filetype.'.vim'
600 endif
601
602 execute ':vsplit '.file
603 execute ':lcd %:p:h'
604 endf
605 nmap <leader>ev :call EditConfig('vimrc')<CR>
606 nmap <leader>ef :call EditConfig('ftplugin')<CR>
607 nmap <leader>es :call EditConfig('syntax')<CR>
608 nmap <leader>ei :call EditConfig('indent')<CR>
609 nmap <leader>eu :UltiSnipsEdit<CR>
610
611 " spell check {{{2
612 " http://tex.stackexchange.com/a/52932
613 let g:myLangList=["en_gb","en_us","de","fr"]
614
615 function! ToggleSpell()
616 if !exists("b:myLang")
617 let b:myLang=0
618 endif
619 execute "setlocal spell!"
620 if (&spell)
621 echo "setlocal spelllang=" g:myLangList[b:myLang]
622 endif
623 endfunction
624
625 function! SwitchSpell()
626 if !exists("b:myLang")
627 let b:myLang=0
628 endif
629 if (&spell)
630 let b:myLang=b:myLang+1
631 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
632 endif
633 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
634 echo "setlocal spelllang=" g:myLangList[b:myLang]
635 endfunction
636
637 nnoremap <silent> coS :call SwitchSpell()<CR>
638 " fix spelling with first choice
639 nnoremap <Leader>f 1z=