How to find visually selected string in different file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to find visually selected string in different file

Ashwin V
Hi,
I am trying to
In a open file sim.log.
1) Visually select a string ( with white space)
2) Split open ~/project/string_file_list and Search this string in
this new open file.
3) map this operation to some key binding.

I could not find any help on web related to this.

Thanks,
Ashiwn.

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to find visually selected string in different file

meino.cramer
Ashwin V <[hidden email]> [11-08-04 06:24]:

> Hi,
> I am trying to
> In a open file sim.log.
> 1) Visually select a string ( with white space)
> 2) Split open ~/project/string_file_list and Search this string in
> this new open file.
> 3) map this operation to some key binding.
>
> I could not find any help on web related to this.
>
> Thanks,
> Ashiwn.
>
> --
> 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
>

Hi Ashiwn,

may be this could be half of the way...
1) in sim.log visually select a string
2) press y (yank the text into the nameless register
3) split open the other file
5) press /CTRL-R"<ENTER>

HTH!

Best regards,
mcc

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to find visually selected string in different file

Jean-Rene David-2
In reply to this post by Ashwin V
* Ashwin V [2011.08.04 00:20]:
> Hi,
> I am trying to
> In a open file sim.log.
> 1) Visually select a string ( with white space)
> 2) Split open ~/project/string_file_list and Search this string in
> this new open file.
> 3) map this operation to some key binding.
>
> I could not find any help on web related to this.

function! SearchInOtherFile()
   let l:other_file="string_file_list"
   let l:saved_reg = @"
   execute "normal! vgvy"
   let l:pattern = escape(@", '\\/.*$^~[]')
   let @/ = l:pattern
   let @" = l:saved_reg
   exe "split " . l:other_file
   normal n
endfunction

vnoremap <silent> <F8> :call SearchInOtherFile()<cr>

Adjust to taste.

HTH,

--
JR

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