VIM - How to map Shift-Enter -
i trying customize behaviour of enter key in normal mode in vim. here .vimrc:
nmap <cr> o<esc> nmap <s-cr> i<cr><esc> i trying make enter append newline after current line when pressed. however, if shift-enter combination pressed, want break current line @ cursor.
the latter not work. whenever press shift-enter appends line without breaking @ cursor.
due way keyboard input handled internally, unfortunately isn't possible today in terminal version of vim (<s-cr> should work in gvim on platforms, , in windows console vim). known pain point, , subject of various discussions on vim_dev , #vim irc channel.
some people (foremost paul leonerd evans) want fix (even console vim in terminals support this), , have floated various proposals, cp. http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8
but of today, no patches or volunteers have yet come forward, though many have expressed desire have in future vim 8 major release.
note on mapping <cr>:
if map <cr> in normal mode, it'll interfere selection of history items in command-line window , jumping error under cursor in quickfix/location list windows! (unless add following:)
:autocmd cmdwinenter * nnoremap <cr> <cr> :autocmd bufreadpost quickfix nnoremap <cr> <cr> note on :nmap:
you should use :noremap; makes mapping immune remapping , recursion.
Comments
Post a Comment