Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I move to end of line in Vim?

I know how to generally move around in command mode, specifically, jumping to lines, etc. But what is the command to jump to the end of the line that I am currently on?

like image 309
salt.racer Avatar asked Sep 19 '08 21:09

salt.racer


People also ask

How do I navigate to the last line in vi editor?

If you're already in vi, you can use the goto command. To do this, press Esc , type the line number, and then press Shift-g . If you press Esc and then Shift-g without specifying a line number, it will take you to the last line in the file.

How do I move text to the next line in Vim?

Just pressing o then Esc whenever you need it isn't bad. This will just insert a new line above or below the current line.

How do you get to the end of a line in insert mode?

Use CTRL + o while in insert mode to temporarily enter normal mode for the next command, and then $ to go to the end of the line (after which you will be returned to insert mode) Use ESC to return to normal mode, and then A which both moves the cursor to the end of the line and enters insert mode.


2 Answers

As lots of people have said:

  • $ gets you to the end of the line

but also:

  • ^ or _ gets you to the first non-whitespace character in the line, and
  • 0 (zero) gets you to the beginning of the line incl. whitespace
like image 41
Rob Wells Avatar answered Sep 29 '22 13:09

Rob Wells


Just the $ (dollar sign) key. You can use A to move to the end of the line and switch to editing mode (Append). To jump the last non-blank character, you can press g then _ keys.

The opposite of A is I (Insert mode at beginning of line), as an aside. Pressing just the ^ will place your cursor at the first non-white-space character of the line.

like image 88
dvorak Avatar answered Sep 29 '22 13:09

dvorak