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

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

  • :windo executes an Ex command in each window of the current tab page
  • diffthis marks each visited window for diff mode
  • Once all windows are marked, Vim aligns differences and enables synchronized diff navigation
  • This avoids repetitive :diffthis calls 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 sbuffer or :vert diffsplit to control layout first
  • :windo is tab-local: run it again in another tab if needed

Next

How do I move the cursor just after each search match instead of at match start?