Skip to content

Reading a diff

The diff renderer, and the keys that make a change readable.

The main pane shows the diff of whatever the panel has under its cursor. This page is about reading it. Staging is about acting on it.

  • Colors the code by language.
  • Marks the words that changed inside a changed line, not only the line.
  • Collapses long runs of unchanged lines, and says how many it hid.

The same renderer draws the read views and the staging editor, so nothing moves under you when you start staging.

Value Result
auto Side by side when the pane is wide, stacked when it is narrow
split Always side by side
stack Always one column
The same hunk shown side by side, with the old lines on the left and the new lines on the right.
split — the two versions sit at the same height.
The same hunk shown in one column, with removed lines above added lines.
stack — one column, which needs less width.

auto is the default. Side by side is easier for a change that rewrites a line, because the two versions sit at the same height. One column is easier in a narrow pane, where two columns leave no room for the code.

Change it in the Options section of ;, or with diffLayout in the configuration.

Keys Action
0 Move into the diff
j / k Scroll one line
d / u Half a page
space / b A page
< / > Top or bottom
esc Back to the panel

From the panel, J and K scroll the diff without moving your focus.

More context, then whitespace, then the whole file — each applied live.
Keys Action
} / { More or fewer unchanged lines around each hunk
ctrl+w Show the whitespace changes
M Show the whole file instead of the hunks
) / ( Change how alike two files must be to count as a rename
+ / _ Give the focused pane more of the screen

) and ( matter when git shows a move as one delete and one add. Lower the number until git pairs them.

Press / to search the view you are reading. stage counts the matches while you type. n and N move through them, and continue from the start after the last one.

Press W on a branch, a tag or a commit to mark it. Every reference you select after that is compared against the mark. The pane then answers “what does this branch change” instead of “what does this commit change”.

Press W again to clear the mark.

Press w to put the cursor on a name and g to open its definition. Read Navigating with LSP.