10

While typing I realize that I need to move to the beginning of the line. Usually I use <Esc> and I. But I am wondering if there is another way to move to the beginning of the line in the insert mode.

  • What platform? Mac Linux Windows GUI or terminal? – broomdodger Jan 25 '14 at 5:18
  • Just to be said, it would certainly be preferable to stick with <Esc> then move, insert, replace or whatever. That way your changes will be registred in the undo tree. – Yannick Jan 27 '14 at 7:34
15

You can use Ctrl-o which switches to normal mode for one command. This allows you to do movements, such as:

  • Ctrl-o, 0 beginning of line
  • Ctrl-o, $ end of line
  • Ctrl-o, f, y find first y in sentence
7

I will remap some shortcut keys in my vimrc, most of them are cursor moving under the Insert mode.

For example, I will use the Emacs-Like (as same as in Linux Terminal) shortcut:

map <C-a> <ESC>^
imap <C-a> <ESC>I
map <C-e> <ESC>$
imap <C-e> <ESC>A
inoremap <M-f> <ESC><Space>Wi
inoremap <M-b> <Esc>Bi
inoremap <M-d> <ESC>cW

That means:

  • Ctrl+a: Go to beginning of the line [Normal Mode && Insert Mode]
  • Ctrl+e: Go to end of line [Normal Mode && Insert Mode]
  • Alt+f: Backward a word [Insert Mode]
  • Alt+b: Forward a word [Insert Mode]
  • Alt+d: Delete a word (backward) [Insert Mode]

Of cause, vim has default shortcut key for Delete a word (forward) [Insert Mode], that is Ctrl+w

0

The Home key works in Vim while in insert mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.