1

Is it possible to define mappings that only get active when a certain spelllang is set?

E.g. I want to set the following mapping, but only if I use spelllang=de.

inoremap oe ö
3

You can use a conditionnal mapping:

inoremap <expr> oe ( &spelllang == "de" ) ? "ö" : "oe"

With <expr> specified Vim knows that when it sees oe as an input it should execute the rest of the mapping as a vimscript expression and map oe to the result of this expression.

Here the expression is a conditionnal operator: if &spelllang == "de" is true then return ö otherwise return oe.

See :h :map-<expr>

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.