Vim tip 18: moving within long lines
Here are Normal mode commands you can use to move within long lines that are spread over multiple screen lines:
- g0 move to the beginning of the current screen line
- g^ move to the first non-blank character of the current screen line
- g$ move to the end of the current screen line
- gj move down by one screen line, prefix a count to move down by that many screen lines
- gk move up by one screen line, prefix a count to move up by that many screen lines
- gm move to the middle of the current screen line
- Note that this is based on the screen width, not the number of characters in the line!
- gM move to the middle of the current line
- Note that this is based on the total number of characters in the line
See :h left-right-motions for more details.
Video demo:
See also my Vim Reference Guide and curated list of resources for Vim.