My version is : NVIM v0.3.0-dev

I'm trying to replace mappings with w mappings. Initially I came up with

nnoremap <leader>w <c-w>
nnoremap <leader>wb <c-w>s
nnoremap <leader>ws <nop>
unmap <c-w>

But it didn't work. I didn't have any mappings with w. After a minute I came up with this:

nnoremap <leader>w <c-w>
nnoremap <leader>wb <c-w>s
nnoremap <leader>ws <nop>
nnoremap <c-w> <nop>

This works as I expect it to. I was just wondering why my previous attempt didn't bear fruit. What's the difference between unmap and nnoremap to <nop> ? And what is the convention to this sort of things.

N.B: I want to unmap cause I'm used to those default keymaps, but I'm having pinky issues with ctrl lately. So, I want to train myself to use mappings instead.

  • 1
    If you dont want to obliterate all the window control keys (some of them are quite useful) the trick I used was nnoremap <Leader>w <C-w>
    – D. Ben Knoble
    Jun 4, 2018 at 13:01

2 Answers 2


It is important to first understand that <c-w> is not a map but a built-in command when vim is operating in a particular mode. It is often referred to as a "normal command" since one uses it in normal mode1, and it can be triggered using the :normal! command. There is no mapping involved; the normal commands are hard coded in C. If you open up normal.c, you can see the character ^W is to associated with the function nv_window in a large, fixed, data table of normal commands.

Although mappings allow you to override default behavior, you cannot change the built-ins and they can always be accessed using noremap, :normal!, feedkeys(..,'n'), etc. When vim is processing input when mappings are allowed, such as in map, :normal, feedkeys(..,'m'), it first checks if there are any mappings which match, then continues processing normal commands or until an invalid sequence is encountered.

This explains why you cannot unmap a built-in normal command and why you can nnoremap to a <nop>, which is specifically designed for this purpose. Why would you choose nnoremap instead of nmap in this case? Well, there's not a great reason, but the convention is to use *noremap always, unless you really need remapping. A good example of when to use an nmap is those to <plug> mappings in a plugin.

Side note: you might wonder why there are the :map and :map! forms in addition to nmap, vmap, etc. Originally, in vi there were two main modes; (normal) command and insert, so having two forms made sense. However, to write robust code, it is almost always better to spell it out in each mode.

1. At one time normal mode was referred to as command mode and visual mode, but forget about this entirely.

  • Good answer. But you didn't specifically say if my 2nd process (one which worked) was correct or not.
    – 3N4N
    Jun 4, 2018 at 11:30

umap XXX may get error if there is no such mapping.

map XXX <Nop> won't get error in that case and can disable vim's original(built in) command, such as d or s or c, while umap can't.


from a plugin named 'vim-sandwich'

NOTE: To prevent unintended operation, the following setting is strongly
      recommended to add to your vimrc.
    nmap s <Nop>
    xmap s <Nop>
      |s| could be easily replaced by |c|l| commands.
KEYMAPPINGS             *sandwich-keymappings*

This plugin defines the following keymappings.

function    default keymappings
add     sa{motion/textobject}{addition} (normal and visual mode)

if we use silent! umap s instead, when we want to use sa, we may actually call the s command because of time out.

  • 4
    What do you mean by "safe"? :silent! unmap XXX is better if you want to silence errors. You also didn't address the difference between the two for builtin commands like C-w
    – D. Ben Knoble
    Feb 17, 2022 at 18:20
  • Thank you. Updated
    – Good Pen
    Feb 21, 2022 at 3:03

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.