I know that I can use either:
i use this command to go to end of line without leaving insert mode
inoremap jl <esc><S-a>
Similarly to go to beginning of line will be:
inoremap jl <esc><S-i>
A shortcut that has worked for me (both muscle memory and intuitiveness) is to map __
(which is a double _
) to "insert at start of current line".
Rationale:
_
already goes to the start of line_
doesn't conflict with any motions (you're already at the start of line)vimscript:
"insert at start of current line by typing in __ (two underscores)
function DoubleUnderscore()
if v:count == 0 && getcurpos()[2] == 1
:silent call feedkeys('I', 'n')
else
:silent call feedkeys('^', v:count + 'n')
endif
endfunction
nnoremap <silent> _ :call DoubleUnderscore()<CR>
It's this complicated because the easy alternative nnoremap __ _I
causes vim to delay on pressing _
to distinguish between _
and __
.
You can map the keys to this:
inoremap II <Esc>I
ref: http://vim.wikia.com/wiki/Quick_command_in_insert_mode