Vim search with multiple windows open

13 views
Skip to first unread message

hilal Adam

unread,
Oct 26, 2011, 10:57:48 PM10/26/11
to v...@vim.org
Hi,

Hope someone could help with this.
My Vim session usually have few vertical/horizantal windows open. Often I do a search within one window and since incsearch is set, screen scrolls down to first match and is highlighted. What I am looking for is to have all occurrences/matches within other windows highlighted as I type within active window.
Please let me know if there is a way to do this.

Thanks

hilal Adam

unread,
Oct 29, 2011, 10:53:48 PM10/29/11
to vim...@googlegroups.com, v...@vim.org
I appreciate it if any help with this question.


From: hilal Adam <hil...@yahoo.com>
To: "v...@vim.org" <v...@vim.org>
Sent: Wednesday, October 26, 2011 9:57 PM
Subject: Vim search with multiple windows open

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Tim Chase

unread,
Oct 29, 2011, 11:30:38 PM10/29/11
to v...@vim.org, hilal Adam
> My Vim session usually have few vertical/horizantal windows
> open. Often I do a search within one window and since
> incsearch is set, screen scrolls down to first match and is
> highlighted. What I am looking for is to have all
> occurrences/matches within other windows highlighted as I type
> within active window. Please let me know if there is a way to
> do this.

I don't know of any way to get all windows to perform an
incsearch in the same way that happens in a single window. From
what I read at ":help 'scrollbind'", I suspect that it's not
something readily possible because each character not only has to
search the current buffer, but all other visible buffers, and it
will timeout after about 0.5sec to keep Vim responsive to your
typing (assuming it was built with +reltime).

However, once the search is completed, setting 'hls' should
highlight the match in all the windows. If the window-content is
similar, you can also try setting 'scrollbind', though that may
be tangential to your question.

-tim


John Little

unread,
Oct 30, 2011, 1:50:18 AM10/30/11
to vim_use
> What I am looking for is to have all occurrences/matches within other windows highlighted as I type within active window.
> Please let me know if there is a way to do this.

Well, I found a way with mappings, but terribly ugly and breaks so
much I'm too ashamed to relate it.

How about, as a half measure, with

:set cpo+=x hlsearch
:cmap <f4> <esc>N/<up>

so while typing your search, press f4 to have the search so far
highlighted by the hlsearch mechanism?
It has side effects, doesn't work well with ? searches, and I'm sure
has other glitches.

(Aside for experts: can vimscript tell, say in a function called by a
mapping using <ctrl-r>=, or in an <expr> mapping, what the current
command mode is? I mean ":", "/" or "?". mode() just returns "c".)

Regards, John

Ben Fritz

unread,
Oct 31, 2011, 10:39:39 AM10/31/11
to vim_use


On Oct 30, 12:50 am, John Little <john.b.lit...@gmail.com> wrote:
>
> (Aside for experts: can vimscript tell, say in a function called by a
> mapping using <ctrl-r>=, or in an <expr> mapping, what the current
> command mode is?  I mean ":", "/" or "?".  mode() just returns "c".)
>

:h getcmdtype()
Reply all
Reply to author
Forward
0 new messages