vi/vim line navigation FAQ: What is the vi command to move to the end of the current line? (Also asked as, how do I move to the end of the current line in vim?)
Short answer
When you’re in vi/vim command mode, use the "$
" character to move to the end of the current line.
Other vi/vim line related commands
For a longer answer, here’s a list of vi/vim “go to line” commands, including the command to go to the end of the line, and many others:
vi command | description |
---|---|
0 |
move to beginning of the current line (this is the number zero) |
$ |
move to end of line |
H |
move to the top of the current window (high) |
M |
move to the middle of the current window (middle) |
L |
move to the bottom line of the current window (low) |
1G |
move to the first line of the file |
20G |
move to the 20th line of the file |
G |
move to the last line of the file |
Just to be clear, you need to be in the vi/vim command mode to issue these commands. Getting into command mode is typically very simple, just hit the [Esc]
key and you are usually there.
Move up or down multiple lines with vim
You can also use the [Up] and [Down] arrow keys to move up and down lines in the vi or vim editor. But did you know that when you're in vi command mode, you can precede the [Up] or [Down] arrow keys with a number? For instance, if you want to move up 20 lines in the current file, you can type this:
20[UpArrow]
vi/vim line navigation - summary
I hope these vi/vim line navigation examples are helpful. If you have any questions, or would like to share your own vi navigation commands, feel free to use the comment form below.