Scrolling down both parts of a split-window at the same time in Vim

前端 未结 6 1667
离开以前
离开以前 2020-12-22 18:50

Is it possible to scroll down the left and right parts of a vertically split window in Vim? I have two files I would like to compare roughly. Each line of these files looks

相关标签:
6条回答
  • 2020-12-22 19:03
    :windo set scrollbind
    

    will set scrollbind in all windows.

    0 讨论(0)
  • 2020-12-22 19:14

    G'day,

    Tried using vimdiff on the two files?

    vimdiff file1 file2
    

    This will give you the scroll binding by default.

    0 讨论(0)
  • 2020-12-22 19:22

    See the documentation for scroll-binding. You'll need to set this for each window that you want bound (e.g. a minimum of 2)

    If you're comparing 2 files, however, vimdiff may be of more use

    0 讨论(0)
  • 2020-12-22 19:25

    Go to the first split, and type in

    :set scrollbind
    

    Go to the next one (ctrl+w), and do the same.

    To disable:

    :set noscrollbind
    

    For more info, check the documentation for scroll binding - http://vimdoc.sourceforge.net/htmldoc/scroll.html#scroll-binding

    0 讨论(0)
  • 2020-12-22 19:28

    From the command line:

    vim -O file1 file2 -c 'windo set scb!'
    

    -O = open side by side.

    -c = what follows in quotes is treated as a vim option.

    'windo' = apply to all panels.

    'scb' = shorthand for scrollbind. Saves some typing, but the two are interchangeable.

    '!' = toggle. This way you can use the same command to turn it off later if you choose to.

    0 讨论(0)
  • 2020-12-22 19:29

    For posterity, here's what I needed to do, since I didn't start with vimdiff.

    I loaded one file. Then :vsp to load the other.

    They are pretty different files, but I wanted to see what's common in between them.

    So...

    :set diff
    :set diffopt=iwhite
    :set scrollbind
    
    0 讨论(0)
提交回复
热议问题