4

I'd like to create a new symbol to use in my vimrc that's <normal>, so I do not have to type <C-\><C-N> to get to do the "go to normal mode" command, nor clutter the vimrc file with combinations that I might not remember.

In C it would have been done with #define, how is this done in VimL?

C like example:

#define <normal> <C-\><C-N>

nmap <leader>q <normal>@q

instead of

nmap <leader>q <C-\><C-N>@q
2
  • Note that I do not wish to use abbreviations or mappings, since these will replace the text.
    – lindhe
    May 14, 2015 at 7:20
  • 1
    I presume you're deliberately using <C-\><C-N> instead of <Esc> because you don't like the beep? Also, surely an nmap means you'll already be in normal mode? Is that just a typo, or am I missing something?
    – Rich
    May 14, 2015 at 15:34

1 Answer 1

4

VimL doesn't have preprocessor macros. You can still do it, sort of, but I'm afraid it's a case of a medicine being worse than the disease it's supposed to cure:

let normal = '<C-\><C-N>'
exe 'nmap <leader>q ' . normal . '@q'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.