Hot answers tagged

47 votes

How do I use Vim as a diff tool?

If you are editing an open file and want to compare it to another file without closing the current one: Open the new file in split screen: For vertical split: :vs otherFile or horizontal split: :...
brother-bilo's user avatar
45 votes

How do I customize vimdiff colors?

One quick fix is to disable syntax highlighting. Sometimes the code syntax highlighting will cause the foreground text to be the same color as the vimdiff background color, making the text "invisible"....
wisbucky's user avatar
  • 910
43 votes
Accepted

How do I customize vimdiff colors?

The colors are controlled by these four highlight groups (:help hl-DiffAdd): DiffAdd diff mode: Added line DiffChange diff mode: Changed line DiffDelete diff mode: Deleted line DiffText diff ...
Ingo Karkat's user avatar
  • 17.7k
23 votes
Accepted

How to make the two windows equal width when comparing files?

You can equalize the size of windows with <c-w>=.
ChoiZ's user avatar
  • 348
23 votes

How do I customize vimdiff colors?

Extending Ingo Karkat's solution to terminal, hi DiffAdd ctermfg=NONE ctermbg=Green hi DiffChange ctermfg=NONE ctermbg=NONE hi DiffDelete ctermfg=LightBlue ctermbg=Red ...
kmario23's user avatar
  • 333
23 votes
Accepted

Using Vimdiff to diff two things that are not local documents

You can diff two unwritten buffers: Open vim (or open a new tab in you current vim instance) Put your current code in one buffer or open an existing file (:e ./mySourceFile) Split your screen with :...
statox's user avatar
  • 49.4k
22 votes
Accepted

How do I enter into vimdiff mode given two splits are already open?

The command is called :diffthis. It must be executed in every window you want to add to the comparison. The inverse is :diffoff which exits diff mode in the current window. To exit diff mode in all ...
Matt's user avatar
  • 20.4k
20 votes
Accepted

Turn off synchronous scrolling not caused by either scrollbind or diff

As Christian Brabandt suggested in a comment, this can be caused by the 'cursorbind' setting. From :help 'cursorbind': When this option is set, as the cursor in the current window moves other ...
16 votes
Accepted

Better diff color scheme

I quite like the diff colors in my colorscheme:
romainl's user avatar
  • 39.2k
14 votes
Accepted

How do I differentiate between vim and vimdiff from within vimrc?

:help diff covers this: In your .vimrc file you could do something special when Vim was started in diff mode. You could use a construct like this: if &diff setup for diff mode ...
Rich's user avatar
  • 31.3k
13 votes

Better diff color scheme

I have a syntax/diff.vim (that I source manually) with the following contents: hi DiffText cterm=none ctermfg=Black ctermbg=Red gui=none guifg=Black guibg=Red hi DiffChange cterm=none ctermfg=Black ...
Luc Hermitte's user avatar
12 votes

How do I differentiate between vim and vimdiff from within vimrc?

You can use the &diff option like in your vimrc: if &diff echo "in diff mode" else echo "not in diff mode" endif See :h 'diff'
statox's user avatar
  • 49.4k
10 votes

How do I customize vimdiff colors?

Another quick (perhaps even lazy) fix is to just do something like: :colo desert This will change your color scheme, and in some cases will make hidden text become visible.
Nathan Chappell's user avatar
8 votes

How to make the two windows equal width when comparing files?

If you want the window widths to remain equal as you change the size of the Vim window, try this in your ~/.vimrc: if exists("##VimResized") if &diff au VimResized * wincmd = ...
garyjohn's user avatar
  • 6,284
8 votes
Accepted

Is there a way to "take both" when using Vim as merge tool?

Not exactly what you asked, but may find this useful: Splice plugin: a Vim plugin for resolving conflicts during three-way merge. It has a nice demo screencast on Vimeo. If you are going to stick ...
mMontu's user avatar
  • 6,600
7 votes
Accepted

Make vim switch to other window after opening a diff

You could add this to your .vimrc: command! -nargs=1 -complete=file Diffsplit diffsplit <args> | wincmd p This create a Diffsplit command (note the capitalized D) which takes one argument and ...
statox's user avatar
  • 49.4k
7 votes

How to diff and merge two directories?

If you just want to just use vimdiff without installing anything extra, the following command will open all the differing files in succession letting you look at the changes with vimdiff: for ...
Jongab's user avatar
  • 71
7 votes
Accepted

Overwrite colorscheme syntax highlighting

DiffAdd and DiffDelete are only used when actually performing a diff ($ vim -d foo.txt bar.txt, $ vimdiff foo.txt bar.txt, $ git mergetool, etc.); those highlight groups are totally irrelevant, here. ...
romainl's user avatar
  • 39.2k
7 votes

Is there a way to "take both" when using Vim as merge tool?

yank and put can work without any plugins or extra functions, though it is, perhaps, a bit less convenient than do or dp Just copy the needed bits from the parent buffers and paste them into the ...
8bittree's user avatar
  • 1,487
7 votes

How can I determine if *any* window in the current tabpage is in diff-mode?

You can sum up the values of &diff for each window, and see if the total is > 0: let any_diff = 0 windo let any_diff += &diff echo any_diff . ' windows in diff mode' if any_diff > 0 | do ...
muru's user avatar
  • 24.7k
7 votes
Accepted

IDE-like inline diff highlighting in Vim

You can do this with the vim-gitgutter plugin. If you're not using git, then Signify has a similar feature. After installing vim-gitgutter, you can switch the highlighting on and off with the ...
Rich's user avatar
  • 31.3k
6 votes

How do I use Vim as a diff tool?

For NeoVim, you can setup your ~/.gitconfig with the following commands git config --global merge.tool nvim git config --global mergetool.keepBackup false git config --global mergetool.nvim.cmd $'...
run_the_race's user avatar
6 votes

Better diff color scheme

My own scheme "Traffic light colors" featuring red, yellow, green and blue. They are a bit gentler in GVim than on the terminal. But they were really designed to be intuitive (for westerners) rather ...
joeytwiddle's user avatar
  • 3,592
6 votes
Accepted

Stop vim from removing whitespace on save for diff files

Since there was nothing explicit in my .vimrc that acted on only-whitespace lines and the diff syntax file did no such thing either, this had to with my plugins somehow. I find out that I had an ...
oligofren's user avatar
  • 1,043
6 votes
Accepted

vimdiff two files, one ro the other rw

You can use startup commands to do this. From :h -c +{command} *-+c* *-c* -c {command} {command} will be executed after the first file has been read (and after ...
DJMcMayhem's user avatar
  • 17.4k
6 votes

Using vim diff to compare the working directory to the HEAD in git?

To view unstaged modifications to your git working tree in vimdiff, try: git difftool --tool=vimdiff or for staged changes git difftool --tool=vimdiff [ --staged | --cached ] These commands are ...
the_velour_fog's user avatar
6 votes
Accepted

If one can diff from Vim without the need to boot `vimdiff` then why is it a binary program?

vimdiff as well as the other binaries are just symbolic links to the actual vim binary. This is done because when vim starts up it checks under which name it has been started and does perform some ...
Christian Brabandt's user avatar
6 votes
Accepted

Turn syntax off only for current buffer/window?

Buffers and windows are different things. To clear syntax for a particular buffer you can set the syntax option to empty string (or even simply do :syntax clear which should be the same for most ...
Matt's user avatar
  • 20.4k
5 votes

Get a vimdiff view of changes made by a patch / diff file

Use: vim <file> +"vertical diffpatch <patch-file>" Note the warning from :help inside this this script I call vimdiffpatch: #!/bin/bash if [[ $# -ne 2 ]]; then echo "Usage: $(...
Tom Hale's user avatar
  • 2,601
5 votes

How do I use Vim as a diff tool?

You can place below mentioned setting in .gitconfig file found in %homepath% (or %userprofile%) directory of the currently logged in user: [diff] tool = vimdiff This will enable git bash tool to ...
RBT's user avatar
  • 151

Only top scored, non community-wiki answers of a minimum length are eligible