Last Updated: November 19, 2020
· underhilllabs

vim: jump to end of line while in Insert Mode

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>$
  • inoremap maps 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:
noremap nnoremap inoremap vnoremap

Related protips:

Basic Vim commands - For getting started

2 Responses
Add your response

Thanks for explanation of using inoremap instead of imap.

over 1 year ago ·

This is great, thank you.
A couple of extra pieces of info for anyone, like me, who is totally new to Vim:
1) This text:
inoremap <C-e> <C-o>$
- should be typed exactly as it is shown, but it is not typed while you are in Vim. It should be placed as a separate line in ~/.vimrc.
2) "C-a" means Ctrl+a, ie hold the Ctrl key down and type a.

over 1 year ago ·