Search code examples
gitvimmergevimdiffmergetool

How to select the entire REMOTE file during mergetool?


I'm using CLI mergetool vimdiff and rather than going line by line and typing :diffg RE for every change to select the REMOTE version, is there a way I can just have the REMOTE version of the entire file as the target merge?


Solution

  • Short answer:

    Use :%diffget to get all chunks.


    Explanation:

    diffget takes - as most vim commands - a range. To quote vimhelp:

                                                            :diffg :diffget
    :[range]diffg[et] [bufspec]
                    Modify the current buffer to undo difference with another
                    buffer.  [...]
                    See below for [range].
    
    [...]
    
    When no [range] is given, the diff at the cursor position or just above it is
    affected.  When [range] is used, Vim tries to only put or get the specified
    lines.
    

    % when used as a range is "equal to 1,$ (the entire file)", see :help :%.