Vim Recall繁體中文

Navigate a long wrapped paragraph

gj or gk

Example

Normal mode with wrap enabled. One file line spans three screen rows. Cursor on the first row.

Before
File line 1 wraps onto three screen rows. Cursor: first screen row of file line 1

  1. gj Next screen row · same file line
  2. gk Previous screen row · same file line

After
After gj: second screen row of file line 1 After gk: first screen row of file line 1

Details & Vim help

Move down or up by display lines instead of file lines.

Stay within a long wrapped line while reading prose.

j and k move file lines. gj and gk are characterwise motions with operators, so do not assume they behave like linewise j or k deletions.

Screen rows depend on window width. gj and gk move between those rows instead of whole file lines.

Try it in Vim

  1. Enable wrapping with :set wrap if needed.
  2. Use gj to go down one displayed row.
  3. Use gk to go back up a displayed row.