Vimdiff

From Jan's Wiki
Revision as of 16:53, 26 November 2013 by Der Jan (talk | contribs) (Created page with "To switch windows in vimdiff or to navigate windows in vimdiff or to change windows in vimdiff try the following: The ":vertical" command can be inserted before another command t…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

To switch windows in vimdiff or to navigate windows in vimdiff or to change windows in vimdiff try the following: The ":vertical" command can be inserted before another command that splits a window.

MOVING BETWEEN WINDOWS

       CTRL-W h        move to the window on the left
       CTRL-W j        move to the window below
       CTRL-W k        move to the window above
       CTRL-W l        move to the window on the right
       CTRL-W t        move to the TOP window
       CTRL-W b        move to the BOTTOM window
 Moving windows

==

       CTRL-W K        move window to the upper
       CTRL-W H        move window to the far left
       CTRL-W J        move window to the bottom
       CTRL-W L        move window to the far right

Source: [1]

==

This looks terrifying at first, but let me explain what is going on. From left to right, top to the bottom:

  • LOCAL — this is file from the current branch
  • BASE — common ancestor, how file looked before both changes
  • REMOTE — file you are merging into your branch`
  • MERGED — merge result, this is what gets saved in the repo

Let’s assume that we want to keep the “octodog” change (from REMOTE). For that, move to the MERGED file (Ctrl + w, j), move your cursor to a merge conflict area and then:

diffget RE

This gets the corresponding change from REMOTE and puts it in MERGED file. You can also:

       :diffg RE  " get from REMOTE
       :diffg BA  " get from BASE
       :diffg LO  " get from LOCAL

Save the file and quit (a fast way to write and quit multiple files is :wqa). Run git commit and you are all set!

[2]