Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move to the beginning of line while in Insert mode

Tags:

vim

I know that I can use either:

  1. Home in insert mode
  2. Esc + i to exit insert mode and enter it again, effectively going to the beginning of line.

But neither satisfies me. In first case I have to tilt my head to hit Home, because I can't blindly hit it. In second case my left arm has to leave the home row to hit Esc, which is annoying too.

Any thoughts?

like image 438
Valentin V Avatar asked Jul 01 '11 07:07

Valentin V


People also ask

How do you enter insert mode and go to the beginning of the line?

Esc + i to exit insert mode and enter it again, effectively going to the beginning of line.

How do you move to the beginning of a line in vim?

Press 0 to go to the beginning of a line, or ^ to go to the first non-blank character in a line.

How do you move in insert mode?

To move from Command mode to Insert mode, press "i" (no quotes). To move from Insert mode to Command mode, press "ESC" (the Escape key). NOTE: If your terminal doesn't have an ESC key, or the ESC key doesn't work, use Ctrl-[ instead.


2 Answers

Ctrl+O whilst in insert mode puts you in command mode for one key press only. Therefore Ctrl+O then Shift+I should accomplish what you're looking for.

like image 183
Greg Sexton Avatar answered Sep 20 '22 15:09

Greg Sexton


You could enter insert mode using I (capital i).

It will put the cursor at the beginning of the line.

Similarly you can use A to add something at the end of the line.

Though, it does not really solve the problem of moving while already being in Insert mode.

I have just checked help on Insert mode, there is no key combination in insert mode to move at the beginning of the line.

Other idea : Remap a new command only in insert mode

inoremap <C-i> <Home>

like image 23
Xavier T. Avatar answered Sep 17 '22 15:09

Xavier T.