2

This is what U wanted to do:

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

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

1
  • See :h :let-option
    – Tommy A
    Feb 24, 2017 at 20:35

1 Answer 1

5

: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 and acknowledge you have read our privacy policy.

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