For example:
sfdAAAzsd
sdfBBBadf
sd1ZZZsdf
Hightlighted:
sfd"AAA"zsd
sdf"BBB"adf
sd1"ZZZ"sdf
all letters will be searched only
As inspired from this answer, we can search with
/\([A-Z]\)\1\{2}
Here is what the pattern after /
does:
[A-Z]
match any uppercase letter A to Z\(...\)
capture this (what is within \(
and \)
) and possibly refer to it later\1
refer to the first item captured with \(...\)
\{2}
match 2 of the preceding items (\1
in this case)Thus the pattern above will match AAA,BBB,...,ZZZ
.
To print the lines that match {pattern} we can use the :g[lobal]
command, that is
:g/{pattern}/
We can omit {pattern} to use the last used search pattern, ie.
:g//