What regex pattern should I use to find two strings with a similar value on successive lines
For example, if I have something like:
(NOTE: the following values are already indented in the front)
end
end
how would I search for this using the vi editor?
EDIT
I would like it to match " end" and " end" or " end" and " end"
Since you mentioned that the values are indented… you can use this pattern to overcome that issue:
/end\n\s*endThe
\sstands for whitespace, meaning it can be either a tab or a space. The*means there can be none or infinite of the preceding character (in this case, whitespace). If you wanted to just match two spaces you could use/end\n endor/end\n\s\send. If you want to match four you could similarly type them all out or do/end\n\s\{4}endto only match 4 whitespace characters (space or tab).I think what you’d really like to do is match identical lines. So you can do
/\(^.*$\)\n\1to accomplish that. If you want a certain number of identical lines you could do/\(^.*$\)\(\n\1\)\{15}(this example uses 15 but you can change that to any number you’d like or switch\{15}with*for any matches.