vi (vim) line navigation FAQ: What is the vi command to move to the end of the current line? (How do I move to the end of the current line in vim?)
Short answer: When in vi/vim command mode, use the "$" character to move to the end of the current line.
While I'm in the vi line neighborhood, here's a longer answer, with a list of "vi/vim go to line" commands:
vi command | description |
---|---|
0 | move to beginning of the current line |
$ | 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.
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]
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.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。