highlight a word following a certain key

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

highlight a word following a certain key

sinbadd
Hi,

i want to hightlight a word following a certain word. For instance.
In the below example, i want to highlight the words that appear after
'key' which are one, two and three. how can i do that?

1.txt:

key one
key two
abc def
key three

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: highlight a word following a certain key

Tim Chase
On 2017-03-01 00:41, sinbad wrote:

> i want to hightlight a word following a certain word. For instance.
> In the below example, i want to highlight the words that appear
> after 'key' which are one, two and three. how can i do that?
>
> 1.txt:
>
> key one
> key two
> abc def
> key three

If you don't mind highlighting the "key" too, you can just use

  /\<key\s\+\w\+

If you don't want the key and the space, you can use

  /key \+\zs\w\+

or

  /\(key \+\)\@<=\w\+

which both do the same sort of thing.  I'm partial to the former
method as it's a little shorter and easier for me to understand.

-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

---
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...