1

I am trying to customize the mappings for vimdiff and make them similar to winmerge

In a vertical 2 way split, I want to map alt-left <a-left> to move current diff to left side and alt-right <a-right> to move current diff to right side.

For merging i can use :diffg and :diffp. But I need to know which split i am in so that i can use :diffg/:diffp in that.

Is there any way by which i can detect which split i am in. Specifically is there is any way by which i can know whether the cursor is in left split or right split

Related Question how-to-get-list-of-files-which-are-currently-being-diffed-in-vim

Community
  • 1
  • 1
Yogesh Arora
  • 2,216
  • 2
  • 25
  • 35
  • I like the question, although i recommend trying to not use the arrows. Part of what's so nice about Vim is that you don't have to move your hands! : ) Using something like alt together with < and > for left and right would kick arse! (Although it wouldn't make sense if you have your diffs horizontally, but i rarely do). – Hannes Mar 19 '10 at 09:26
  • i am using `` and `` because i have also mapped `` and `` to move to next or prev diff. This just makes things more intutive. As i already said i am doing this because vim doesnt come naturally to me , i m more used to wokring with and IDE like eclipe/visual studio – Yogesh Arora Mar 19 '10 at 15:48

2 Answers2

1

Assuming there are only two windows, the winnr() function will return 1 for the first window and 2 for the second window. You can also use winnr('$') to find out how many windows there are: :echo winnr('$').

You can also just use dp and do, then you don't need to jump betweem windows as much, and it's easier to reach than the arrow keys.

too much php
  • 88,666
  • 34
  • 128
  • 138
  • dp do may be easy, but it doesn't come naturally to me. I have been forced on to vim from IDE world, but now i am trying to make vim map to what i used in IDE. This exercise has made me learn much more about vim than just commands – Yogesh Arora Mar 19 '10 at 04:34
1

Not an answer to your specific question, but here are some nice diff tweaks that might help.

"" Diff options; ignore whitespace.
set diffopt+=iwhite

I don't like the :diffon :diffoff because they mess with word wrap (turns it on when exiting diff). So i only set diff, scrollbind, foldmarker and foldcolumn.

"" Diff 'd' {{{
    nmap <silent> ,dd :set diff scb fdm=diff fdc=2<CR>
    nmap <silent> ,dD :windo :set diff scb fdm=diff fdc=2<CR>
    nmap <silent> ,do :set nodiff noscb fdm=manual fdc=0<CR>
    nmap <silent> ,dO :windo :set nodiff noscb fdm=manual fdc=0<CR>
    "nmap <silent> ,dd :diffthis<CR>
    "nmap <silent> ,dD :windo :diffthis<CR>
    "nmap <silent> ,do :diffoff<CR>
    "nmap <silent> ,dO :windo :diffoff<CR>
    nmap <silent> ,du :diffupdate<CR>
"" }}}

Also, check out the DirDiff plugin for diffing directory trees if you haven't already...

Hannes
  • 1,871
  • 3
  • 15
  • 20