vi - Add new line after current line in insert mode vim -
i new @ vim, , transition sublime vim being hard. want know if there's shortcut add new line above or behind current line while i'm in insert mode without leaving it. in sublime used
cmd + enter
cmd + shift + enter
to didn't find similar way on vim.
i found way in normal mode using 'o' , 'o' , configuring amazing way http://vim.wikia.com/wiki/insert_newline_without_entering_insert_mode none of them reach need.
thanks !
defining shortcut adding line below easy, type following on vim command-line (after typing : in normal mode) or add vimrc file:
imap <c-enter> <esc>o that adds insert-mode mapping (imap) ctrl-enter leave insert mode, use o add new line after current line (leaving in insert mode started). (<c-xxx> how vim represents special key sequence ctrl+xxx, , <esc> escape key).
that's similar "amazing way" link to, using appropriate key sequence go insert mode normal mode , add line. way create shortcuts in vim build them smaller pieces. if know o , o need create mapping normal mode first use them.
from that, should obvious how other mapping too:
imap <c-s-enter> <esc>o (<c-s-xxx> means ctrl+shift+xxx)
those mappings work fine me in gvim gui may not work in terminal-based vim, key sequences might not passed correctly terminal vim. use other mappings such ctrl+o if necessary.
Comments
Post a Comment