Saturday, January 10, 2015

Re: restrict searches by window

On Thu, Jan 8, 2015 at 2:09 PM, Charles Campbell
<Charles.E.Campbell@nasa.gov> wrote:
> kamaraju kusumanchi wrote:
>> Is it possible to restrict searches by window? For example, if I open
>> two files by
>>
>> vim -o file1.txt file2.txt
>>
>> I want to search for expr1 in file1.txt, expr2 in file2.txt. The
>> hlsearch option should work so that it will highlight different words
>> in different buffers. Is anything like that possible currently?
>>
>> I am using vim 7.4.488 on Debian Jessie.
>>
> Use :match instead of hlsearch:
>
> :match Search /pattern/
>

Hmm... I want all the functionalities that come with searching for a
pattern. Not just highlighting. For example, I want to be able to use
'n' key to move across searches while the search pattern is different
across windows.

Let me explain the problem I am trying to solve... may be that will
provide more context.

I am working on a large code base (mostly C++) spanned across multiple
files and directories. Initially I am working in file1.cpp and say I
searched for functionA and moved a bunch of lines below to modify its
definition. Now I open another file using ":vert sf file2.cpp" (since
file2.cpp could be in a different directory other than :pwd), search
for patternB in it. There could be multiple hits for it ... so I drill
down to the line of interest using 'n' key. My idea is to copy lines
around patternB from file2.cpp into file1.cpp and then close
file2.cpp. But since I searched for patternB in file2.cpp, it is no
longer the search pattern in file1.cpp. I would have to do /<UP> to
get back to the previous search. But this will move the cursor focus.

I am surprised that no one has requested this feature so far. May be
there is an easy to do what I am after? I am sure people here work on
big complicated code bases all the time...

raju
--
Kamaraju S Kusumanchi
http://malayamaarutham.blogspot.com/

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: