3 " Author:   Samir Benmendil <samir.benmendil[at]gmail[dot]com>
 
   8 set runtimepath& " reset rtp
 
   9 " remove all autocommands
 
  12 set runtimepath+=$XDG_DATA_HOME/vim/vundle
 
  13 call vundle#rc('$XDG_DATA_HOME/vim')
 
  15 Plugin 'gmarik/vundle'
 
  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 'shougo/vimproc.vim'
 
  33 Plugin 'shougo/unite.vim'
 
  34 Plugin 'sjl/gundo.vim'
 
  35 Plugin 'tomtom/tcomment_vim'
 
  36 Plugin 'tpope/vim-endwise'
 
  37 Plugin 'tpope/vim-fugitive'
 
  38 Plugin 'tpope/vim-repeat'
 
  39 Plugin 'tpope/vim-surround'
 
  40 Plugin 'tpope/vim-unimpaired'
 
  41 Plugin 'valloric/youcompleteme'
 
  42 Plugin 'vim-scripts/yankring.vim'
 
  45 Plugin 'sirver/ultisnips'
 
  46 Plugin 'honza/vim-snippets'
 
  49 Plugin 'kana/vim-textobj-user'
 
  50 Plugin 'julian/vim-textobj-variable-segment'
 
  51 Plugin 'sgur/vim-textobj-parameter'
 
  54 Plugin 'ompugao/ros.vim'
 
  55 Plugin 'ompugao/ctrlp-ros'
 
  57 " seems to have problems right now... may be add later?
 
  58 " Plugin 'jalcine/cmake.vim'
 
  59 " Plugin 'powerman/vim-plugin-viewdoc'
 
  61 " find an alternative (latex-box? Automatic Latex Plugin?)
 
  62 Plugin 'http://git.code.sf.net/p/vim-latex/vim-latex'
 
  63 " Plugin 'lokaltog/vim-easymotion'
 
  64 Plugin 'justinmk/vim-sneak'
 
  65 Plugin 'chrisbra/checkattach'
 
  66 Plugin 'nathanaelkane/vim-indent-guides'
 
  68 Plugin 'vim-scripts/mediawiki.vim'
 
  70 " remove entries first
 
  71 set runtimepath -=$HOME/.vim
 
  72 set runtimepath -=$HOME/.vim/after
 
  73 set runtimepath -=$XDG_CONFIG_HOME/vim
 
  74 set runtimepath -=$XDG_CONFIG_HOME/vim/after
 
  75 " then prepend and append them
 
  76 set runtimepath ^=$XDG_CONFIG_HOME/vim
 
  77 set runtimepath +=$XDG_CONFIG_HOME/vim/after
 
  79 filetype plugin indent on
 
  86 " moving around, searching and patterns {{{2
 
  87 set incsearch           " show match for partly typed search command
 
  88 set ignorecase          " ignore case when using a search pattern
 
  89 set smartcase           " override 'ignorecase' when pattern has upper case characters
 
  90 set hlsearch            " highlight all matches for the last used search pattern
 
  92 set nostartofline       " don't move the cursor to the first non-blank char of a line
 
  93 set path=.,include/,../include/,/usr/include/c++/*,/opt/ros/hydro/include
 
  95 " displaying text {{{2
 
  96 set scrolloff=5                 " number of screen lines to show around the cursor
 
  97 set nowrap                      " long lines wrap
 
  98 set linebreak                   " wrap long lines at a character in 'breakat'
 
  99 set showbreak=↪                 " show these chars for wrapped lines
 
 101 set lazyredraw                  " don't redraw while executing macros
 
 103 set list                        " show chars defined in 'listchars'
 
 104 set listchars=tab:❭\            " list of strings used for list mode
 
 105 set listchars+=extends:❯,precedes:❮
 
 106 " Only shown when not in insert mode
 
 109     au InsertEnter * :set listchars-=trail:·
 
 110     au InsertLeave * :set listchars+=trail:·
 
 113 set sidescroll=1                " number of collumns to scroll
 
 114 set sidescrolloff=1             " don't scroll over the listchars
 
 116 set fillchars=diff:⣿,vert:│
 
 118 set nonumber                    " show the line number for each line
 
 119 set norelativenumber            " show the relative line number for each line
 
 121 " syntax, highlighting and spelling {{{2
 
 122 set synmaxcol=800               " don't highlight long lines
 
 124 set dictionary=spell            " list of dictionary files for keyword completion
 
 128 " multiple windows {{{2
 
 129 set laststatus=2                " 0, 1 or 2; when to use a status line for the last window
 
 131 set previewheight=20            " default height for the preview window
 
 135 " set splitbelow                  " a new window is put below of the current one
 
 136 set splitright                  " a new window is put right of the current one
 
 141 " using the mouse {{{2
 
 142 set mouse=rnv                   " list of flags for using the mouse
 
 143 set ttymouse=xterm              " type of mouse
 
 145 " messages and info {{{2
 
 146 set showcmd                     " Show (partial) command in status line.
 
 147 set ruler                       " show the cursor position all the time
 
 148 set confirm                     " Ask what to do when closing unsaved documents
 
 149 set shortmess=filnxtoOI         " don't show intro message
 
 152 set backspace=indent,eol,start  " allow backspacing over everything in insert mode
 
 154 set showmatch                   " Show matching brackets.
 
 156 set nojoinspaces                " don't use two spaces after '.' when joining a line
 
 157 set formatoptions=jcrnql
 
 159 set nrformats=hex               " number formats recognized for CTRL-A and CTRL-X commands
 
 161 set complete=.,w,b,u,t
 
 162 " whether to use a popup menu for Insert mode completion
 
 163 set completeopt=longest,menuone,preview
 
 165 " tabs and indent {{{2
 
 166 set shiftwidth=4                " number of spaces used for each step of (auto)indent
 
 167 set smarttab                    " a <Tab> in an indent inserts 'shiftwidth' spaces
 
 168 set softtabstop=4               " if non-zero, number of spaces to insert for a <Tab>
 
 169 set shiftround                  " round to 'shiftwidth' for "<<" and ">>"
 
 170 set expandtab                   " expand <Tab> to spaces in Insert mode
 
 173 set pastetoggle=<F11>           " key sequence to toggle paste mode
 
 176 set foldmethod=marker           " folding type
 
 177 set foldlevelstart=0            " value for 'foldlevel' when starting to edit a file
 
 179 " save and restore folds
 
 180 set viewoptions=cursor          " only save cursor position
 
 183 set diffopt=filler,vertical
 
 185 " reading and writing files {{{2
 
 186 set modeline                    " read modelines
 
 187 set modelines=2                 " only check first/last 2 lines
 
 189 set writebackup                 " write a backup file before overwriting a file
 
 190 set backup                      " keep a backup after owerwriting a file
 
 191 set backupdir=$XDG_CACHE_HOME/vim/backup//
 
 193 set backupskip+=.netrc          " skip netrc
 
 194 set backupskip+=/dev/shm/pass*  " skip passwordstore files
 
 196 set undofile                    " persistent undo history
 
 197 set undodir=$XDG_CACHE_HOME/vim/undo//
 
 201     au BufWritePre .netrc         setlocal noundofile
 
 202     au BufWritePre /dev/shm/pass* setlocal noundofile
 
 203     au BufWritePre /tmp/*         setlocal noundofile
 
 206 set autowrite                   " automatically write a file when leaving a modified buffer
 
 207 set autoread                    " automatically read a file that has been modified
 
 211 set directory=$XDG_CACHE_HOME/vim/swap//
 
 213 " command line editing {{{2
 
 214 set history=5000                " how many command lines are remembered
 
 215 set wildmenu                    " command-line completion shows a list of matches
 
 216 set wildmode=longest:full,full  " specifies how command line completion works
 
 218 set wildignore+=.hg,.git,.svn                    " Version control
 
 219 set wildignore+=*.aux,*.out,*.toc                " LaTeX intermediate files
 
 220 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg   " binary images
 
 221 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
 
 222 set wildignore+=*.spl                            " compiled spelling word lists
 
 223 set wildignore+=*.sw?                            " Vim swap files
 
 224 set wildignore+=*.luac                           " Lua byte code
 
 225 set wildignore+=*.pyc                            " Python byte code
 
 226 set wildignore+=*.orig                           " Merge resolution files
 
 229 set virtualedit=block           " let cursor move past last char in <C-V> mode
 
 230 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
 
 232 set viewdir=$XDG_CACHE_HOME/vim/view//
 
 235 " Resize splits when the window is resized {{{2
 
 238     autocmd VimResized * :wincmd =
 
 241 " Only show cursorline in the current window and in normal mode {{{2
 
 244     au WinLeave,InsertEnter * set nocursorline
 
 245     au WinEnter,InsertLeave * set cursorline
 
 248 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
 
 251     au StdinReadPost * :set buftype=nofile
 
 254 " Jump to last known cursor position {{{2
 
 257     " blacklist certain filetype
 
 258     let blacklist = ['gitcommit']
 
 259     autocmd BufReadPost *
 
 260                 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
 
 261                 \   exe "normal! g`\"" |
 
 267 " allow both <space> and / to be <leader>
 
 271 nnoremap <leader>r :make<cr>
 
 272 nnoremap <leader><cr> :make<cr>
 
 275 nnoremap <silent> <Leader>/ :silent nohl<CR>
 
 278 nnoremap <leader>[ :tabprev<cr>
 
 279 nnoremap <leader>] :tabnext<cr>
 
 281 " paste from selection
 
 282 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
 
 283 " paste from clipboard
 
 284 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
 
 286 " Clean trailing whitespace
 
 287 nnoremap <silent> <leader>ww m':%s/\s\+$//<cr>:let @/=''<cr>``zz
 
 290 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
 
 291 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
 
 293 " jump to last cursor position
 
 296 " Select (charwise) the contents of the current line, excluding indentation.
 
 300 nnoremap U :syntax sync fromstart<cr>:AirlineRefresh<cr>:redraw!<cr>
 
 303 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
 
 304 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
 
 311 " display the number of matches for the last search
 
 312 nmap <Leader># :%s:<C-R>/::gn<CR>
 
 314 " center cursor after search and open folds
 
 320 " same when jumping around
 
 323 nnoremap <c-o> <c-o>zzzv
 
 325 " Not using the default mappings of 'To line from top/bottom'
 
 331 " Heresy, emacs insert bindings
 
 332 inoremap <c-a> <esc>I
 
 333 inoremap <c-e> <esc>A
 
 334 cnoremap <c-a> <home>
 
 337 " proper movement when lines are wrapped
 
 338 noremap <expr> j (v:count == 0 ? 'gj' : 'j')
 
 339 noremap <expr> k (v:count == 0 ? 'gk' : 'k')
 
 345 noremap  <Right> <NOP>
 
 347 inoremap <Down>  <NOP>
 
 348 inoremap <Left>  <NOP>
 
 349 inoremap <Right> <NOP>
 
 351 cnoremap <Down>  <NOP>
 
 352 cnoremap <Left>  <NOP>
 
 353 cnoremap <Right> <NOP>
 
 355 cnoremap <C-J>   <Down>
 
 356 cnoremap <C-H>   <Left>
 
 357 cnoremap <C-L>   <Right>
 
 359 " close all folds open fold in cursor
 
 362 map <F1> :ls<CR>:b<space>
 
 364 nnoremap <C-L> <C-W>w
 
 365 nnoremap <C-H> <C-W>W
 
 367 "xterm mouse with middleclick paste
 
 368 nnoremap <MiddleMouse> i<MiddleMouse>
 
 369 vnoremap <MiddleMouse> s<MiddleMouse>
 
 371 " fix legacy vi inconsistency
 
 374 " allow repeat operator on visual
 
 375 vnoremap . :normal .<CR>
 
 377 " add line without changing position or leaving mode
 
 378 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
 
 379 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
 
 381 " Don't use Ex mode, use Q for formatting
 
 384 " break undo sequence before removing word
 
 385 inoremap <C-W> <C-G>u<C-W>
 
 387 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
 
 388 nnoremap [oe :set expandtab<CR>
 
 389 nnoremap ]oe :set noexpandtab<CR>
 
 391 for idt in range(1,8)
 
 392   exe 'nnoremap co'.idt.' :set tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
 
 395 " space will toggle current fold in normal mode
 
 396 nnoremap <leader><Space> za
 
 397 " create folds around visual selection
 
 398 vnoremap <leader><Space> zf
 
 400 autocmd BufWinLeave *.* mkview
 
 401 autocmd BufWinEnter *.* silent loadview
 
 404 cnoremap w!! w !sudo tee % > /dev/null
 
 406 " uppercase previous word
 
 407 inoremap <C-C> <Esc>gUiwgi
 
 409 " plugins options {{{1
 
 411 let g:airline#extensions#whitespace#enabled = 1
 
 412 let g:airline#extensions#tabline#enabled = 1
 
 413 let g:airline_powerline_fonts = 1
 
 416 let g:checkattach_filebrowser = 'ranger'
 
 417 let g:checkattach_once = 'y'
 
 420 let delimitMate_expand_cr = 2
 
 421 let g:delimitMate_expand_space = 1
 
 424 nnoremap <silent> <Leader>ff :FSHere<CR>
 
 425 nnoremap <silent> <Leader>fl :FSRight<CR>
 
 426 nnoremap <silent> <Leader>fh :FSLeft<CR>
 
 427 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
 
 428 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
 
 431 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
 
 432 " delete fugitive buffers when closed
 
 433 autocmd BufReadPost fugitive://* set bufhidden=delete
 
 435 nnoremap <silent> <leader>gs :Gstatus<CR>
 
 436 nnoremap <silent> <leader>gd :Gdiff<CR>
 
 437 nnoremap <silent> <leader>gc :Gcommit -v<CR>
 
 438 nnoremap <silent> <leader>ga :Gwrite<cr>
 
 439 nnoremap <silent> <leader>gb :Gblame<cr>
 
 442 nnoremap <F7> :GundoToggle<CR>
 
 445 let g:indent_guides_default_mapping = 0
 
 446 let g:indent_guides_guide_size = 1
 
 447 nmap <silent> cog <Plug>IndentGuidesToggle
 
 448 nmap <silent> [og <Plug>IndentGuidesEnable
 
 449 nmap <silent> ]og <Plug>IndentGuidesDisable
 
 452 " open/close NERDTree with \e
 
 453 nmap <Leader>e :NERDTreeToggle<CR>
 
 454 nmap <F6> :NERDTreeToggle<CR>
 
 455 " <space> to open files/dirs
 
 456 let NERDTreeMapActivateNode='l'
 
 457 " close vim if only NERDTree is open
 
 458 autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
 
 462 let g:pymode_rope_completion = 0
 
 463 let g:pymode_rope = 0
 
 464 let g:pymode_folding = 1
 
 465 let g:pymode_lint_ignore = "E221,E266,E501"
 
 466 let g:pymode_syntax_space_errors = 0    " don't bother me when I'm typing
 
 469 let g:syntastic_enable_highlighting = 0
 
 470 let g:syntastic_error_symbol='E'
 
 471 let g:syntastic_style_error_symbol='S'
 
 472 let g:syntastic_warning_symbol='W'
 
 473 let g:syntastic_style_warning_symbol='S'
 
 474 let g:syntastic_always_populate_loc_list=1
 
 475 nmap <silent> <leader>y :SyntasticCheck<cr>
 
 478   let g:syntastic_check_on_open=1
 
 482 map <F5> :TagbarToggle<cr>
 
 483 let g:tagbar_sort = 0
 
 484 let g:tagbar_compact = 1
 
 485 let g:tagbar_autoshowtag = 1
 
 486 let g:tagbar_width = 25
 
 487 let g:tagbar_iconchars = ['+', '-']
 
 490 let g:UltiSnipsEditSplit = 'vertical'
 
 491 let g:UltiSnipsSnippetsDir = expand("$XDG_CONFIG_HOME/vim/ultisnips")
 
 492 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
 
 493 let g:UltiSnipsExpandTrigger       = "<tab>"
 
 494 let g:UltiSnipsJumpForwardTrigger  = "<tab>"
 
 495 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
 
 497 " UltiSnips completion function that tries to expand a snippet. If there's no
 
 498 " snippet for expanding, it checks for completion window and if it's shown,
 
 499 " selects first element. If there's no completion window it tries to jump to
 
 500 " next placeholder. If there's no placeholder it just returns TAB key
 
 501 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
 
 502 function! g:UltiSnips_Complete()
 
 503     call UltiSnips#ExpandSnippet()
 
 504     if g:ulti_expand_res == 0
 
 508             call UltiSnips#JumpForwards()
 
 509             if g:ulti_jump_forwards_res == 0
 
 516 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
 
 517 let g:UltiSnipsListSnippets="<c-e>"
 
 520 call unite#filters#matcher_default#use(['matcher_fuzzy'])
 
 521 call unite#custom#profile('default', 'context', {
 
 523             \ 'direction': 'botright'
 
 526 nnoremap [unite] <Nop>
 
 527 nmap <leader>u [unite]
 
 530 " seems not respected
 
 531 let g:unite_source_grep_max_candidates = 2000
 
 533     " Use ag in unite grep source.
 
 534     let g:unite_source_grep_command = 'ag'
 
 535     let g:unite_source_grep_default_opts = '--smart-case -w --vimgrep --hidden --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
 
 536     let g:unite_source_grep_recursive_opt = ''
 
 538 nnoremap <silent> [unite]a :<C-u>Unite grep -input=
\12\17<CR>
 
 540 " unite-file_rec {{{3
 
 542     " Use ag in unite rec source
 
 543     let g:unite_source_rec_async_command = 'ag --follow --nocolor --nogroup --hidden -g ""'
 
 545 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
 
 548 call unite#custom#default_action('buffer', 'goto')
 
 549 nnoremap <silent> [unite]b :<C-u>Unite buffer<CR>
 
 552 let g:unite_source_menu_menus = {}
 
 553 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
 
 554 let g:unite_source_menu_menus.fugitive.command_candidates = {
 
 555             \ 'Gstatus <Leader>gs' : 'Gstatus',
 
 556             \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
 
 560 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
 
 562 let g:unite_source_history_yank_enable = 1
 
 563 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
 
 566 nnoremap <silent> <leader>p :YRShow<cr>
 
 567 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
 
 568 let g:yankring_replace_n_pkey = ''
 
 569 let g:yankring_replace_n_nkey = ''
 
 571 " map Y to y$ for the yank ring
 
 572 function! YRRunAfterMaps()
 
 573     nnoremap Y   :<C-U>YRYankCount 'y$'<CR>
 
 577 let g:ycm_extra_conf_globlist = ['~/src/*','/mnt/data/src/*']
 
 578 let g:ycm_global_ycm_extra_conf = expand('$XDG_CONFIG_HOME/vim/ycm_extra_conf.py')
 
 579 let g:ycm_extra_conf_vim_data = ['getcwd()']
 
 580 let g:ycm_add_preview_to_completeopt = 1
 
 581 let g:ycm_autoclose_preview_window_after_insertion = 0
 
 582 "let g:ycm_extra_conf_vim_data = ['%:p']
 
 583 nnoremap <leader>jd :YcmCompleter GoTo<CR>
 
 585 " vim-easy-align {{{2
 
 586 " start interactive EasyAlign in visual mode
 
 587 vmap <Enter> <Plug>(EasyAlign)
 
 590 let g:vim_json_syntax_conceal = 0
 
 593 let g:tex_flavor='latex'
 
 594 let g:Tex_DefaultTargetFormat='pdf'
 
 595 let g:Tex_MultipleCompileFormats='pdf'
 
 598 let g:sneak#streak = 1
 
 599 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
 
 600 let g:sneak#use_ic_scs = 1  " follow 'ignorecase' and 'smartcase'
 
 618 " Convenient command to see the difference between the current buffer and the
 
 619 " file it was loaded from, thus the changes you made.
 
 620 " Only define it when not defined already.
 
 621 if !exists(":DiffOrig")
 
 622   command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
 
 623                   \ | wincmd p | diffthis
 
 627 function! EditConfig(what)
 
 628     let l:dir = split(&runtimepath,',')[0]
 
 630         let l:file = expand($MYVIMRC)
 
 631     elseif ! isdirectory(globpath(l:dir, a:what))
 
 632         echoe a:what." is not valid!"
 
 633     elseif empty(&filetype)
 
 634         echoe 'filetype is empty!'
 
 636         let l:file = l:dir.'/'.a:what.'/'.&filetype.'.vim'
 
 639     execute ':vsplit '.file
 
 642 nmap <leader>ev :call EditConfig('vimrc')<CR>
 
 643 nmap <leader>ef :call EditConfig('ftplugin')<CR>
 
 644 nmap <leader>es :call EditConfig('syntax')<CR>
 
 645 nmap <leader>ei :call EditConfig('indent')<CR>
 
 646 nmap <leader>eu :UltiSnipsEdit<CR>:lcd %:p:h<CR>
 
 649 " http://tex.stackexchange.com/a/52932
 
 650 let g:myLangList=["en_gb","en_us","de","fr"]
 
 652 function! ToggleSpell()
 
 653   if !exists("b:myLang")
 
 656   execute "setlocal spell!"
 
 658     echo "setlocal spelllang=" g:myLangList[b:myLang]
 
 662 function! SwitchSpell()
 
 663   if !exists("b:myLang")
 
 667     let b:myLang=b:myLang+1
 
 668     if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
 
 670   execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
 
 671   echo "setlocal spelllang=" g:myLangList[b:myLang]
 
 674 nnoremap <silent> coS :call SwitchSpell()<CR>
 
 675 " fix spelling with first choice
 
 676 nnoremap <Leader>f 1z=