I've started using nvim (neovim) recently. It generally works well, but when I run vimdiff, I noticed that I got the startup errors I got when I ran regular vim. I've fixed those so that both vim and nvim run without errors on my system, so vimdiff works fine now. But it makes me wonder: is there a neovim version of vimdiff? Or should I just maintain both vim and neovim so that regular vim works fine for vimdiff?
Asked
Active
Viewed 8,118 times
17
-
1`vimdiff` is just vim as if the `-d` option is given. It even links to plain vim. Doesn't neovim have -d? And what happens if you symlink vimdiff to neovim? – Gavin Haynes Jan 01 '22 at 22:37
-
I see. So the vim executable conditionally behaves based upon the name of arg[0], and if it is `vimdiff` then behave like -d was passed. If I symlink vimdiff to nvim as you suggest, then it just behaves like nvim with two files passed to it (no diff is done). Making an nvimdiff doesn't work either. I assume it must not have this conditional behavior. I can use `-d` as you suggest. @GavinHaynes, if you post the suggestion of `-d` as an answer, I'll accept it. – firebush Jan 03 '22 at 19:53
3 Answers
18
Yeah, you can use the -d
option to open nvim in diff mode.

Gavin Haynes
- 1,721
- 11
- 21
-
2and `tool = nvimdiff` in `[diff]` section of your .gitconfig if you use Git! – bcag2 Dec 05 '22 at 13:01
3
I noticed a question about this was posted on redit: https://www.reddit.com/r/neovim/comments/6rvsa2/nvimdiff/
The dialog there confirms that there is no corresponding nvimdiff that is shipped. The solution suggested there is to add an alias in your bashrc file:
alias vimdiff='nvim -d'
I'll do this.

firebush
- 5,180
- 4
- 34
- 45
-
Ever got this to work? neither this suggestion nor putting `tool = nvim -d` in gitconfig seem to work. – oarfish Sep 07 '22 at 12:04
-
@oarfish: This question pertains to using nvimdiff on the shell, not configuring git to use neovim. Per the accepted answer, I got vimdiff to work by aliasing it to `nvim -d`. That said, as far as git and `nvim -d` is concerned, this may be helpful to you: https://stackoverflow.com/a/61299449/629530 – firebush Sep 08 '22 at 20:40
-
Aliasing doesn't seem to make sense, since git wouldn't have access to the shell alias by the time it tries to launch nvim. I got it to work using the solution in my own answer though. – Janus Troelsen Apr 22 '23 at 20:25
0
Git supports NeoVim natively since v2.29.0 from 2020.
- docs: Documentation/mergetools/vimdiff.txt
- commit: https://github.com/git/git/commit/11868978c7c80d3c29071b29e7964e3d62523819
You can try it out temporarily using e.g.
git -c 'diff.tool=nvimdiff' difftool

Janus Troelsen
- 20,267
- 14
- 135
- 196