'Vim Regex: How do I match a literal "greater than" (">") / "less than" ("<") symbol?

Vim. Regex. How do I match this > and this <.



Solution 1:[1]

< and > are special regex characters that do not need to be escaped in vim (they need to be escaped to make them special) so you should be able to just do:

 :s/>/x/g

Solution 2:[2]

To match this > AND this <, you can do :%s/[<>]/x/g

In that case, you would replace all < and > with "x."

If you want to search without replacing, you can just do /[<>] and then use n and shift+n to move forward and backward to each instance of the match.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user2199860
Solution 2 dukeEllington32