Search code examples
vimkeymapping

Execute mapped command in vim without hitting return


I use the Voom outliner plugin in vim and mapped a command to :

:map <M-o> :VoomToggle markdown

The mapping works but when I use it, it just puts the command into the command line of vim. I still have to hit return for execution. How can the command applied automatically without hitting return?


Solution

  • You need to include the concluding Enter in the mapping, just as you'd type it.

    :map <M-o> :VoomToggle markdown<CR>
    

    Vim uses a special notation, like in the mapping keys; see :help key-notation.

    Also, you should use :noremap; it makes the mapping immune to remapping and recursion.