Writing :set noremap ö : in vim works fine, but with my .vimrc file containing:

set noremap ö :

I get the following error:

Error detected while processing /home/anna/.vimrc:
line    1:
E518: Unknown option: ö 
Press ENTER or type command to continue

What am I doing wrong?

  • 1
    Set sets options, map makes mappings. :h :map – D. Ben Knoble Jan 10 '19 at 1:13
  • Oooh such a mistake. Sorry for not double-checking my question! – user20488 Jan 10 '19 at 1:15
  • Seems I can't downvote my own post – user20488 Jan 10 '19 at 1:15

It appears the OP was actually trying to define a mapping as opposed to doing a set on 'remap'. That was unexpected and, unfortunately, I had written a good part of the dissertation below before finding out. Ah well, in for a penny, in for a pound...I finished it in case it might be useful to someone.

The option 'remap' takes a boolean value. If you want to disable recursive mapping globally (you really shouldn't do this, see below) then you want :set noremap. To enable it's :set remap. To toggle the value :set remap!. To set it to the default value (enabled) :set remap&.

Please note the help for this setting :h 'remap'.

Allows for mappings to work recursively...NOTE: To avoid portability problems
with Vim scripts, always keep this option at the default "on".  Only switch it
off when working with old Vi scripts.

What that means is you will want to do, for example,

:nnoremap lhs rhs

...instead of...

:nmap lhs rhs

In fact, there's almost no reason to ever use the recursive/:map variations. So it's understandable why one would want to use the global setting. But it's better to follow Vim's advice and get in the habit of using non-recursive commands when defining each mapping.

Note: there are a lot of entries already on this site that talk about why recursive can be an issue. Here are a couple that do so and are also high quality, useful answers about mapping in general:

There's also this chapter in the excellent guide Learn Vimscript The Hard Way. To quote part of it...

When should you use these nonrecursive variants instead of their normal counterparts?


No, seriously, always.

Take this with a small grain of salt. They're rare but there are legitimate reasons for using recursive mapping. (And by the time one recognizes such a use case one is likely to have a good understanding of the risks and use the feature wisely, if at all. With a nod to @DBenKnoble.)

(BTW depending on your level of experience you might want to read the two chapters that precede the linked one while you're at it as they discuss mapping starting with the basics.)

| improve this answer | |
  • The only recursive :maps I see are those that need to expand <Plug> (or the ones I write that depend on surround.vim and custom text objects...) – D. Ben Knoble Jan 10 '19 at 1:20
  • @D.BenKnoble I'm pretty sure I've had an actual, practical need to use a recursive mapping myself ONCE. I'm trying to remember what the use case was... – B Layer Jan 10 '19 at 1:35
  • 1
    This mapping has to be recursive, and I find it quite practical. I agree with your advice though: always use the non-recursive variants. By the time you need one, you'll know what you're doing well enough to accept the risk. – D. Ben Knoble Jan 10 '19 at 1:42
  • 1
    To your last sentence: Exactly! – B Layer Jan 10 '19 at 1:48