rawat89
rawat89

Reputation: 21

vim search simultaneously across all split files

Is there a way to similary scroll to simultaneously go to next search instance on all split files? Currently I am using :windo // to search in all splits but pressing "n" only goes to next instance in active split window.

I have 2 different files open in vim split and am looking to jump the the next instance of searched string in both simultaneously.

For context: When we use the vimdiff on 2 similar files, searching for a string and pressing "n" lets us scroll to the next match in all files. Looking for something similar.

Upvotes: 0

Views: 289

Answers (1)

romainl
romainl

Reputation: 196926

When you diff two files, the option :help 'scrollbind' is enabled, which synchronizes the scroll of the two windows. You can run the following command in each window to have the same behavior:

:set scrollbind

or this single command to cover every window:

:windo set scrollbind

Note that it doesn't work the way you described. The non-focused window doesn't exactly scroll to the next match, all it does is scroll in the same direction and by the same amount as the focused window.

Upvotes: 0

Related Questions