HMK
HMK

Reputation: 574

How to synchronize cursor movement in multiple split windows?

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.

Upvotes: 15

Views: 4691

Answers (1)

mhinz
mhinz

Reputation: 3361

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.

Upvotes: 21

Related Questions