Search code examples
regexvimgrepspecial-charactersend-of-line

search from end of line to next line


I am on Unix using gvim and grep.

Problem 1:

I need to search an xml file for the following pattern:

< sample1>
< /sample1>

So the problem is the pattern crosses a line. I am new to gvim and grep and could'nt figure this out using my regex/special characters knowledge.

Problem 2:

One additional problem is, there is white space before the less than sign (<) in the second line. i.e.

< sample1>
 < /sample1>

Could anyone please suggest how I can search for these patterns?


Solution

  • To search for this pattern in Vim use the / command in normal mode:

    /< sample>\n< \/sample1>
    

    Notice that the / character on the second line has to be escaped using the \ character.