Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight multiple lines between two search patterns in gvim

I am trying to highlight multiple lines that match between two words which are present on two different lines.

1.Todo: used for the todo comments (ones that have "TODO: something" in them)
2.Comment: indicates a code comment.
3.Statement: a code statement like a for loop
4.Type: a user defined type generally
5.PreProc: a pre-processor statement like #include <stdio.h>

To highlight between todo and something on single line we use /todo.*something

but to highlight between todo and stdio(which is present on 5th line) is there any command.

Thanks.

like image 436
Eashwar Gadanchi Avatar asked Aug 02 '17 10:08

Eashwar Gadanchi


People also ask

How do you highlight in Gvim?

If you want to select the entire line in a file, press V. Now when you press k or j to go up and down, vim will select the entire line above and below your cursor. Finally, you can select text in columns by pressing ctrl+v and moving up or down the block.

How do I highlight multiple lines in vi?

Manipulate multiple lines of text Press Shift+V to enter line mode. The words VISUAL LINE will appear at the bottom of the screen. Use navigation commands, such as the Arrow keys, to highlight multiple lines of text.


1 Answers

you can make use \_. to include linebreaks. For the example todo ... stdio, you can try:

/todo\_.\{-}stdio
like image 85
Kent Avatar answered Sep 18 '22 17:09

Kent