How do I enable diff mode in every open split at once?
Answer
:windo diffthis<CR>
Explanation
If you already have several related files open in splits, enabling diff mode one window at a time is slow and error-prone. :windo diffthis applies :diffthis to every open window in the current tab, so you can switch into comparison mode in one command. This is especially useful during refactors where you need to compare generated files, config variants, or staged/manual edits side by side.
How it works
:windoexecutes an Ex command in each window of the current tab pagediffthismarks each visited window for diff mode- Once all windows are marked, Vim aligns differences and enables synchronized diff navigation
- This avoids repetitive
:diffthiscalls and ensures you do not miss a split
Example
Suppose you have these files open in splits:
app.conf
app.conf.staging
app.conf.production
Run:
:windo diffthis
All splits immediately enter diff mode, and you can use diff motions such as ]c and [c to jump between change hunks.
Tips
- Use
:diffoff!to disable diff mode in all windows when you are done - For two-way comparisons, combine with
:vert sbufferor:vert diffsplitto control layout first :windois tab-local: run it again in another tab if needed