5

On Ubuntu 18.04, git mergetool --tool-help results in:

'git mergetool --tool=<tool>' may be set to one of the following:
        araxis

The following tools are valid, but not currently available:
    bc
    bc3
    codecompare
    deltawalker
    diffmerge
    diffuse
    ecmerge
    emerge
    examdiff
    kdiff3
    meld
    opendiff
    p4merge
    tkdiff
    tortoisemerge
    vimdiff
    vimdiff2
    vimdiff3
    winmerge
    xxdiff

I would like to use vimdiff with mergetool but after googling I can't get it listed as 'available'.

jsstuball
  • 4,104
  • 7
  • 33
  • 63
  • Corrected the typo in the question, I wasn't spelling `vimdiff` wrong. – jsstuball Mar 29 '19 at 13:13
  • Was the next line of output going like this : "*Some of the tools listed above only work in a windowed environment. If run in a terminal-only session, they will fail.*"? Because it seems to say so in the [doc](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration). – Romain Valeri Mar 29 '19 at 13:16
  • Yes it was. I thought the ones which required a GUI were `gvimdiff`, `gvimdiff2` etc. – jsstuball Mar 29 '19 at 13:20
  • @RomainValeri, by "terminal-only" session, does it include for example a different tty without X? If so, I can use `vimdiff` there as a mergetool. – padawin Mar 29 '19 at 13:27
  • 2
    On my systems, `vimdiff` is just a symbolic link to `vim`. The ubuntu ones use a crazy mess of `/etc/alternatives` sometimes but ultimately you just invoke vim *as* vimdiff to get vimdiff out of it. – torek Mar 29 '19 at 13:48

2 Answers2

4

Actually, it turns out the answer is that vim is not shipped with Ubuntu 18.04 and other versions, even though I've been using vim.tiny for months via the vi command, which is in the PATH on installation.

Installing vim via apt install vim will also install vimdiff, among other utilities. Now the mergetool can be configured to vimdiff.

jsstuball
  • 4,104
  • 7
  • 33
  • 63
  • Here's what I get on Ubuntu 18.04: ```vimdiff Command 'vimdiff' not found, but can be installed with: sudo apt install vim ``` ```sudo apt install vim Reading package lists... Done Building dependency tree Reading state information... Done vim is already the newest version (2:8.0.1453-1ubuntu1.1). 0 upgraded, 0 newly installed, 0 to remove and 25 not upgraded. ``` – user3610279 Sep 03 '19 at 16:57
0

Does it work if you add the following in your ~/.gitconfig:

[merge]
    tool = vimdiff

?

padawin
  • 4,230
  • 15
  • 19
  • This is what I get when I run `git mergetool` after configuring `vimdiff` as the tool: `The merge tool vimdiff is not available as 'vim'` – jsstuball Mar 29 '19 at 13:16
  • 2
    But....that's the point of the `--tool` option : being able to use a tool *without* setting it in config. – Romain Valeri Mar 29 '19 at 13:25
  • 1
    Fair point @RomainValeri. Maybe silly question, but is vimdiff installed on your machine? I had a look at my output of `git mergetool --tool-help`, vimdiff was available, but for example `meld` was not, after I installed `meld` it became available in the list. – padawin Mar 29 '19 at 13:34
  • @padawin I think you're in fact right : I've overlooked something here with the software being installed on the system. I have to look into this. The crazy thing is.... here on a Windows machine without vimdiff I just had it in the "may be set" part of the list. And my actually configured (and VERY windowed) tool, BeyondCompare is listed under "not available".... what the hell. – Romain Valeri Mar 29 '19 at 13:44