How do I put all visible windows into diff mode and balance their sizes in Vim?
Answer
:windo diffthis | wincmd =<CR>
Explanation
When you already have multiple related buffers open, you can enter diff mode across all visible windows in one shot and then normalize layout width/height immediately. This avoids the slow loop of switching windows and running :diffthis repeatedly. Pairing it with wincmd = makes the comparison easier to read because each pane gets equal space.
How it works
:windo diffthis | wincmd =<CR>
:windo diffthisexecutes:diffthisin every window in the current tab|chains another Ex command on the same command linewincmd =equalizes split sizes after diff mode is active<CR>executes the full command chain
Example
Suppose you have three windows open: current branch file, generated output, and a manually edited variant. Running the command immediately highlights differences in all panes and rebalances window sizes so each diff is readable.
Window 1: config-old.yml
Window 2: config-new.yml
Window 3: config-expected.yml
After execution, all three participate in diff mode with synchronized fold and hunk navigation behavior.
Tips
- Use
:diffoff!later to clear diff mode everywhere - Run this per tab page so unrelated windows in other tabs are untouched