Insert a newline without entering in insert mode, vim

helq picture helq · Apr 21, 2013 · Viewed 38.4k times · Source

I want insert newlines in normal mode in vim using Shift-Enter and Ctrl-Enter. I try some solutions and mixing solutions from Vim Wikia - Insert newline without entering insert mode but Shift-Enter and Ctrl-Enter didn't respond:

" put a new line before or after to this line
nnoremap <S-CR> m`o<Esc>``
nnoremap <C-CR> m`O<Esc>``

" reverse J command
nnoremap <C-J> vaW<Esc>Bi<CR><Esc>k:s/\s\+$//<CR>$

Answer

TKrugg picture TKrugg · Apr 21, 2013

My alternative is using oo (resp. OO) to insert a new line under (resp. over) the current through this mapping: nmap oo o<Esc>k (resp. nmap OO O<Esc>j)