m (fix strike through) |
(Change <tt> to <code>, perhaps also minor tweak.) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | {{TipImported |
||
− | {{Tip |
||
|id=1058 |
|id=1058 |
||
+ | |previous=1055 |
||
− | |title=Selecting changes in diff mode |
||
+ | |next=1059 |
||
− | |created= |
+ | |created=2005 |
|complexity=intermediate |
|complexity=intermediate |
||
|author=Kartik Agaram |
|author=Kartik Agaram |
||
|version=6.0 |
|version=6.0 |
||
|rating=6/3 |
|rating=6/3 |
||
+ | |category1= |
||
− | |text= |
||
+ | |category2= |
||
− | Assumption: 2-window vertical diff mode |
||
⚫ | |||
+ | This tip is for when you are working with a two-window vertical diff (comparing two files, side-by-side). |
||
+ | Use <code>]c</code> and <code>[c</code> to go to a specific change. Then use M-, and M-. to patch using the version on the left or right respectively. The cursor is then positioned in the file that changed for ease of saving, etc. |
||
− | The idea: Use ]c and [c to go to a specific change. |
||
− | Then use M-, and M-. to patch using the version on the left or right respectively. |
||
− | The cursor is then positioned in the file that changed for ease of saving, etc. |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | <pre> |
||
⚫ | |||
+ | function! DiffTake(dir, oppdir) |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | + | function! SetupDiffMappings() |
|
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | </pre> |
||
⚫ | |||
− | function! SetupDiffMappings() |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
+ | <pre> |
||
⚫ | |||
⚫ | |||
− | Kartik Agaram, November 24, 2005 22:59 |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | </pre> |
||
+ | ---- |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
⚫ |
Latest revision as of 06:06, 13 July 2012
Tip 1058 Printable Monobook Previous Next
created 2005 · complexity intermediate · author Kartik Agaram · version 6.0
This tip is for when you are working with a two-window vertical diff (comparing two files, side-by-side).
Use ]c
and [c
to go to a specific change. Then use M-, and M-. to patch using the version on the left or right respectively. The cursor is then positioned in the file that changed for ease of saving, etc.
I find this more intuitive than using diffput and diffget because I no longer need to remember which window the cursor is in.
The code:
function! DiffTake(dir, oppdir) let l:old = winnr() exec "wincmd ".a:dir " Assumption: just 2 windows side by side. if (winnr() == l:old) diffput exec "wincmd ".a:oppdir else wincmd p diffget endif endfunction function! SetupDiffMappings() if &diff map <Esc>, :call DiffTake("h", "l")<CR> map <Esc>. :call DiffTake("l", "h")<CR> endif endfunction " vim -d call SetupDiffMappings() " Entering diff mode from within vim - diffsplit, etc. autocmd FilterWritePost * call SetupDiffMappings()
Comments[]
You might also like these settings (but it will require a little savy on keeping which side is which):
" <F11> moves to "previous" change location, " <F12> moves to "next" change location, map <F11> [c map <F12> ]c " SHIFT<F12> does a "diff put" change location, map <S-F12> dp