Moving around in insert mode


Set up h, j, k, l keys so that you can move in insert mode without exiting it; my preferred option is to use Alt as the prefix:

inoremap <A-h> <C-o>h
inoremap <A-j> <C-o>j
inoremap <A-k> <C-o>k
inoremap <A-l> <C-o>l

It is very useful to also be able to go to the beginning/end of the line while in insert mode without exiting it:

inoremap <A-4> <C-o>$
inoremap <A-0> <C-o>0

Some other commands can be useful too:

inoremap <A-f> <C-o><C-f>
inoremap <A-b> <C-o><C-b>
inoremap <A-g> <Del>
inoremap <A-t> <Backspace>
inoremap <A-n> <CR>

Optionally, the same commands can be defined for normal mode for command consistency:

nnoremap <A-h> h
nnoremap <A-j> j
nnoremap <A-k> k
nnoremap <A-l> l
nnoremap <A-4> $
nnoremap <A-0> 0
nnoremap <A-f> <C-f>
nnoremap <A-b> <C-b>

In order to prevent <A-f> opening the File menu, <A-h> opening the Help menu (and so on) we can use:

set winaltkeys=no

Photo credit: Image by Clker-Free-Vector-Images from Pixabay