Create a command in vim for all modes -


if want remap <c-s> :w<cr> i'd have this

nnoremap <c-s> :w<cr> inoremap <c-s> <esc>:w<cr> 

since insert mode requre escaping normal mode before entering command (sure, <esc> wouldn't kill anything, it's ugly, terminal bell goes off , other modes available [n, i, v, s, x, c , o] there plenty of cases <esc> wouldn't cut it).

is there easy way map command "for modes" in vim?

you can quite close taking advantage of ctrl-\ ctrl-n command. ctrl-\ ctrl-n goes normal mode mode.

we can define 2 mappings identical right-hand side cover normal, visual, select, operator-pending, insert, , command-line mode.

noremap  <c-s> <c-\><c-n>:write<cr> noremap! <c-s> <c-\><c-n>:write<cr> 

see :h ctrl-\_ctrl-n.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -