Search code examples
vimvim-pluginsurround

How to disable internal key bindings in vim?


I am using surround vim plugin and it incorporates the use of s key but my s key is bind by default to deleting the character under the cursor and then immediately putting me in the insert mode. I tried to insert the following line in my ~/.vimrc file as directed at this link but it didn't work:

map <s> <Nop>

Solution

  • OK, first off, vim-surround absolutely does not change your mappings for s. It does map to ds, ys, and cs, as well as S in visual mode. But it does not change your default s mapping.

    Even if it did, this wouldn't cause any issues. You don't need to unmap something for another map to work. Instead the new mapping applies over the original one.

    But still to answer your actual question about disabling default key bindings, you have the basic idea but made one tiny mistake. The brackets around s are not needed. Try adding:

    map s <Nop>
    

    Instead.

    If you really want to do this, even though it is unnecessary for working with vim-surround, I would recommend using nnoremap instead of map. The differences between them are summarized here.