vimtricks.wiki Concise Vim tricks, one at a time.

How do I jump to the first non-blank character of the next or previous line in a single motion?

Answer

+ and -

Explanation

The + and - motions jump to the first non-blank character of the next or previous line respectively — combining vertical movement and ^ into a single, count-aware keystroke.

How it works

  • + (or <CR> in normal mode) — move down one line and land on the first non-blank character
  • - — move up one line and land on the first non-blank character

Unlike j and k, which preserve the column position, + and - always land on the first meaningful character of the target line. Both accept a [count] prefix: 3+ jumps down 3 lines to the first non-blank.

Example

    def greet():
        print("hello")

With the cursor anywhere on the first line, pressing + moves to p (the p of print), not the column below the cursor. Pressing j would move to the same column as the cursor's current position.

Tips

  • + is exactly equivalent to pressing <Enter> in normal mode — the two share the same behavior
  • Particularly useful in macros and operator-pending mode: d+ deletes from the current line through the first non-blank of the next line
  • {count}- jumps up {count} lines to the first non-blank, equivalent to {count}k^ in fewer keystrokes
  • Useful in visual mode to extend a selection: V3+ selects the current through the next 3 lines (with cursor landing on first non-blank)

Next

How do I jump to a tag in Vim and automatically choose if there is only one match?