1

this is what i wanted to do:

function! Spell(lang)
  if a:lang == "off"
    set nospell
  else
    set spell
    set spelllang=a:lang
  endif
endfunction

unfortunately this does not work ;( this assigns the string a:lang to spelllang.

  • See :h :let-option – Tommy A Feb 24 '17 at 20:35
2

:exe and :let (and some other commands like :echo or :call) are basically the only ex commands that expect variables. Almost all other ex commands do not expect such things and therefore take it literally. Therefore you have to use :exe "set spelllang=".a:lang or even better, use :let &spelllang=a:lang (see :h :let-option).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.