Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go to beginning of line without opening new line in VI

Tags:

vim

vi

People also ask

What vi command allows you to move immediately to the beginning of a line?

Moving to Start or End of LinePress ^ to move the cursor to the start of the current line. Press $ to move the cursor to the end of the current line.

How do you jump in front 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 I navigate to the end of a line in vi?

Short answer: When in vi/vim command mode, use the "$" character to move to the end of the current line.


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.


A simple 0 takes you to the beginning of a line.

:help 0 for more information


Try this Vi/Vim cheatsheet solution to many problems.

For normal mode :
0 - [zero] to beginning of line, first column.
$ - to end of line


You can use 0 or ^ to move to beginning of the line.
And can use Shift+I to move to the beginning and switch to editing mode (Insert).


There is another way:

|

That is the "pipe" - the symbol found under the backspace in ANSI layout.

Vim quickref (:help quickref) describes it as:

N      |      to column N (default: 1)

What about wrapped lines?

If you have wrap lines enabled, 0 and | will no longer take you to the beginning of the screen line. In that case use:

g0

Again, vim quickref doc:

 g0   to first character in screen line (differs from "0"
      when lines wrap)