One of the things I miss from emacs is being able to jump to the end of the current line while in insert mode with
C-e. So I decided to write a new key mapping to recreate it.
inoremap <C-e> <C-o>$
inoremapmaps a key combination for insert mode
<C-e>is the keybinding I am creating.
<C-o>is a command that switches vim to normal mode for one command.
$jumps to the end of the line and we are switched back to insert mode.
This keybinding allows you to instead jump to beginning of a line while in insert mode.
inoremap <C-a> <C-o>0
*Using inoremap instead of imap
These keybindings could also be written using
imap instead of
inoremap. The difference between the two commands, is that inoremap is non-recursive. So if somewhere in your .vimrc or a plugin
C-o is remapped with:
imap <C-o> <esc>O
Then the above remappings of
<C-e> (with imap) would be changed also and no longer work. So in general it is best to remap with the nore (non-recursive) versions: