Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to synchronize cursor movement in multiple split windows?

Tags:

vim

I remember Notepad++ has this feature, which is really helpful to compare files. I want to realize the similar one in Vim. When moving cursor in one split, cursors in the other split windows will move automatically.

like image 990
HMK Avatar asked Sep 11 '13 09:09

HMK


People also ask

How do I move my cursor from one monitor to another using the keyboard?

Is there a keyboard shortcut to move the cursor from one monitor to another in Windoows 7 (dual monitors)? Win + Shift + Arrow will move the active window from one monitor to the other.


1 Answers

Depending on what you're after, I see 2 possibilities.


1) Diffing windows

If you want to compare files, have a look at :help diff. E.g.

You're on the shell:

$ vimdiff file1 file2 or $ vim -d file1 file2

You have one window open already:

:vertical diffsplit foo.c

You have 2 windows open already:

Do :diffthis in each of them.


2) Scrollbinding windows

You might also like :help 'scrollbind' and :help scroll-binding, if you don't want to jump into diff mode. Thus in the easiest case it's only doing :set scrollbind in both windows.

like image 60
mhinz Avatar answered Oct 03 '22 11:10

mhinz