Friday, February 25, 2011

Re: Is it possible to automatically identify the current line with [I?

On Fri, Feb 25, 2011 at 12:44 PM, Michael(Xi Zhang)
<michaelxmail@gmail.com> wrote:
> On Fri, Feb 25, 2011 at 9:05 AM, Shawn Young <spacephys@gmail.com> wrote:
>>
>> Hello,
>>
>> I apologize if this has already been answered but a search using "[I"
>> in the archive had zero hits, and a google search just sent me to vim
>> oriented web pages; I'm not sure if there is a better way to do the
>> search.
>>
>> So, my question is, is it possible to do something similar to [I and
>> get a listing of all lines that contain the text under the cursor, but
>> where the current line is also marked?
>>
>> For instance if I was on a line like:
>>
>> Fee Fie Foe Foo
>>
>> and my cursor was on the Foe, if I use [I I get something like:
>>
>> 300 Fee Fie Foe Fum
>> 421  Fee Fie Foe Foo
>> 449 The giant said Fee Fio Foe Fum
>> 471  Fee Fie Foe Foo
>> 523  Fie Foo Fee Foe
>>
>> It is not clear which line my cursor is on, it would be helpful if I
>> saw something like:
>>
>> 300 Fee Fie Foe Fum
>> 421  Fee Fie Foe Foo
>> 449 The giant said Fee Fio Foe Fum
>> 471*  Fee Fie Foe Foo
>> 523  Fie Foo Fee Foe
>>
>> so that I knew that I was on line 471 instead of 421.
>>
>> Thanks in advance for any help,
>>
>> Shawn
>>
>>
>> --
>> Shawn Young
>
> You can try  :vimgrep /<C-R><C-W>/j %<cr>
> The command will search the word under the cursor in current file(% -
> current file). The results are in quickfix window. If you don't use the
> option 'j', it will jump to the first search result.
>
> Then you need use :cw<cr> to open the quickfix window.
>
> Or you can combine the two command together:  :vimgrep /<C-R><C-W>/j %<cr>
> \| :cw <cr>
>

Thanks Michael,

I have not tried to put this in my .vimrc yet, but in doing it
manually I don't see anything that indicates which line my cursor is
on. What should I see?

-shawn
> Or map the command to shortcut, for example:
> map  <F6>   <Esc>:vimgrep /<C-R><C-W>/j %<cr> \| :cw<cr>
>
> Check out
> :help vimgrep
>
> Michael
>
>

--
Shawn Young
SpacePhys@Gmail.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

No comments:

Post a Comment