Friday, April 29, 2011

Re: Language switching shortcuts

Kevin Steinhardt wrote:

> All, ...
>
> I'm a real noob when it comes to vim but I *am* learning. I'm
> currently writing a lot in Dutch as well as English, but not really in
> the same document. Is there a way to set let's say <F11> as a
> 'English' key and <F12> as a 'Nederlands' key, executing the commands
> below:
>
>    <F11> would do `set spelllang=en_gb` then `set spell`
>    <F12> would do `set spelllang=nl` then `set spell` also
>
> I'm not interested in localisation strings changing or my menus in
> gvim turning to Dutch; basically, just the spelllang parameter.
>
> I hope there's a way to execute more than one command with a single
> key.
>
> Cheers
> Kevin Steinhardt

Hi

Here is what I have in my ~/.vimrc to:

- toggle on/off spelling checker by pressing F8
- rotate though the spelling languages that I use
by pressing F7

Changing it to use other languages should be trivial:

if has('spell')
set spell

if has('eval')
" Rotate through languages of spelling checker.
let g:myLangIdx = 0
let g:myLangCodes = [ "en_us", "eo", "fr", "it", "br", "nl" ]
let g:myLangs = [ "language:", "lingvo:", "langue :", "lingua:",
"yezh:", "taal:" ]
function! MySpellLang()
let g:myLangIdx = g:myLangIdx + 1
if g:myLangIdx >= len(g:myLangs) | let g:myLangIdx = 0 | endif

exe "setlocal spell spelllang=" . g:myLangCodes[g:myLangIdx]
echo g:myLangs[g:myLangIdx] g:myLangCodes[g:myLangIdx]
endf

map <F7> :call MySpellLang()<CR>
imap <F7> <C-o>:call MySpellLang()<CR>
endif
map <F8> :set spell!<CR>
endif

-- Dominique

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: