copy highlighted text after : prompt

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

copy highlighted text after : prompt

Daniel Fetchinson
Hi folks,

I use * regularly to search for words and the results are nicely
highlighted. Many times I need to copy these terms after the : prompt
(what is its name? command prompt? status bar?) for example when I
need to grep for it in other files or search-and-replace it, etc.

Is this possible?

Cheers,
Daniel


--
Psss, psss, put it down! - http://www.cafepress.com/putitdown

--
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: copy highlighted text after : prompt

Benjamin Esham
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daniel Fetchinson wrote:

> I use * regularly to search for words and the results are nicely
> highlighted. Many times I need to copy these terms after the : prompt
> (what is its name? command prompt? status bar?) for example when I need to
> grep for it in other files or search-and-replace it, etc.
>
> Is this possible?

Hi Daniel,

Are you aware that if you leave the search field "blank", i.e.

  :s//replacement/

then Vim just uses the most recent search text?  This means that if you use
the * command to search for a word, and then execute the command above, the
word will be replaced with "replacement" without you needing to type it in.
Similarly, you could do

  :g//

to find all occurrences of the most recent search term in the file.

HTH,
- --
Benjamin D. Esham   |   [hidden email]
“Quidquid latine dictum sit, altum viditur.”
                    (Whatever is said in Latin sounds profound.)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (Darwin)

iEYEARECAAYFAkxkIvcACgkQzOC3TdZ2u5r+mACg0qflgICn2u0I7uqvZcVBu4yY
7bkAmwTvXNE9I9o9qJISIuI38fL+24+Y
=2YNB
-----END PGP SIGNATURE-----

--
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: copy highlighted text after : prompt

Tim Chase
In reply to this post by Daniel Fetchinson
On 08/12/10 10:47, Daniel Fetchinson wrote:
> I use * regularly to search for words and the results are nicely
> highlighted. Many times I need to copy these terms after the : prompt

Sounds like you're looking for Control+R followed by Control+W

   :help c_ctrl-R_ctrl-W

Very handy indeed.

-tim


--
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: copy highlighted text after : prompt

Daniel Fetchinson
>> I use * regularly to search for words and the results are nicely
>> highlighted. Many times I need to copy these terms after the : prompt
>
> Sounds like you're looking for Control+R followed by Control+W
>
>    :help c_ctrl-R_ctrl-W
>
> Very handy indeed.

Yes! Thanks a lot!

Cheers,
Daniel


--
Psss, psss, put it down! - http://www.cafepress.com/putitdown

--
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: copy highlighted text after : prompt

Daniel Fetchinson
In reply to this post by Benjamin Esham
>> I use * regularly to search for words and the results are nicely
>> highlighted. Many times I need to copy these terms after the : prompt
>> (what is its name? command prompt? status bar?) for example when I need to
>> grep for it in other files or search-and-replace it, etc.
>>
>> Is this possible?
>
> Hi Daniel,
>
> Are you aware that if you leave the search field "blank", i.e.
>
>   :s//replacement/
>
> then Vim just uses the most recent search text?

No, I was not aware of that! This is brilliant, the only reason I'm
not surprised is that I got used to the fact that whatever I ask on
this list I always get the exact thing in a response along the line
"vim already makes this very simple, here is how" :)


> This means that if you use
> the * command to search for a word, and then execute the command above, the
> word will be replaced with "replacement" without you needing to type it in.
> Similarly, you could do
>
>   :g//
>
> to find all occurrences of the most recent search term in the file.

This is uber-cool too!

Cheers,
Daniel


--
Psss, psss, put it down! - http://www.cafepress.com/putitdown

--
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: copy highlighted text after : prompt

Benjamin Esham
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daniel Fetchinson wrote:

> Benjamin Esham wrote:
>
> > Are you aware that if you leave the search field "blank", i.e.
> >
> >   :s//replacement/
> >
> > then Vim just uses the most recent search text?
>
> No, I was not aware of that! This is brilliant, the only reason I'm not
> surprised is that I got used to the fact that whatever I ask on this list
> I always get the exact thing in a response along the line "vim already
> makes this very simple, here is how" :)

;-)

- --
Benjamin D. Esham   |   [hidden email]
“White shores and beyond. A far green country, under a swift sunrise.”
“Well...  That isn’t so bad.”
“No...  No it isn’t.”               — Gandalf and Pippin in RotK
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (Darwin)

iEYEARECAAYFAkxkZSIACgkQzOC3TdZ2u5pApQCgtQdHbq9yr8ICP65G2NP3Q4k9
acYAoOW/xoh7fCSgIBzHQgdoM5+X20jU
=4w0W
-----END PGP SIGNATURE-----

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