In Emacs, C-o or M-x open-line creates a blank new line under the point/cursor without moving it.
Since c-l isn't used in insert mode and I like I have the following two lines in my .vimrc.
" C-o from emacs (open line at current point)
inoremap <c-o> <esc><esc>mpA<cr><esc><esc>`pa
" make C-l do C-o's job
inoremap <c-l> <c-o>
This mapping has a number of drawbacks
- It clobbers whatever is in the
pregister - If I use the
c-obinding when my cursor is at the beginning of the line, after executingc-omy cursor is at position 1 instead of position 0. - I have
set so=7so that I always see seven lines around my cursor if possible. If I'm near the bottom of this window invokingc-ocounts as cursor movement
Is there a way of adding a new line below the cursor without changing its position or using a register?
:inoremap <silent> <c-o> <c-o>:call append('.',"")<cr>? Note: I woudln't recommend mapping<c-l>instead based on your warning. – Greg Nisbet Jul 03 '16 at 20:21[<space>and]<space>put a blank line before/after the cursorline. – Al.G. Jul 04 '16 at 12:51