vim - Dynamically change spell checking on a key stroke -


hello discovered spelllang if vim. trying achieve following:

  1. when press f7 dialogue opened asking me if want activate french or english dictionary set spelllang=fr spell or set spelllang=en spell
  2. when press f7 again spell disabled

can in vimrc ?

cheers (i using gvim , windows guess won't matter)

yes can achieve this. wrote little script illustration. can put .vimrc.

the key point use of inputlist() prompts user enter number. of course can expand spelllang_list contains list of possible languages desire.

function! <sid>togglespell()     let spelllang_list = [ 'fr', 'en' ]     let string = []      in range(len(spelllang_list))         call add(string, i+1 . ") " . spelllang_list[i])     endfor      if ! &spell         let &spell = 1         let selection = inputlist(string)         let &spelllang = spelllang_list[selection-1]     else         let &spell = 0         echo "'spell' disabled..."     endif endfunction  noremap <f7> :call <sid>togglespell()<cr> 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -