]> git.rmz.io Git - dotfiles.git/blobdiff - vim/vimrc
vim: add function to switch spelllang
[dotfiles.git] / vim / vimrc
index ffd37968062ad30c5bb251336c20e144afe4c1ce..841be45427e20d41fe1bae6824c51ff7c5951103 100644 (file)
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -89,8 +89,21 @@ syntax on
 
 set spelllang=en_gb             " list of accepted languages
 set dictionary=spell            " list of dictionary files for keyword completion
-" toggle spell-checking
-map <silent><F10> :set nospell!<CR>:set nospell?<CR>
+" Spell Check http://tex.stackexchange.com/a/52932
+let b:myLang=0
+let g:myLangList=["nospell","en_gb","en_us","de","fr"]
+function! ToggleSpell()
+  let b:myLang=b:myLang+1
+  if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
+  if b:myLang==0
+    setlocal nospell
+  else
+    execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
+  endif
+  echo "spell checking language:" g:myLangList[b:myLang]
+endfunction
+map <F10> :call ToggleSpell()<CR>
+imap <F10> <C-O>:call ToggleSpell()<CR>
 
 if has("autocmd")
     au Filetype *