Go to beginning of line without opening new line in VI

rix picture rix · Apr 20, 2012 · Viewed 186.3k times · Source

For ages now I've used SHIFTO and SHIFT$ to move to the beginning and end of a line in vi.

However SHIFTO is more for opening a new line above the cursor.

Is there any command which just takes you to the start of a line?

Answer

Xavier T. picture Xavier T. · Apr 20, 2012

You can use ^ or 0 (Zero) in normal mode to move to the beginning of a line.

^ moves the cursor to the first non-blank character of a line
0 always moves the cursor to the "first column"

You can also use Shifti to move and switch to Insert mode.