I have a following line:

   <a href="/episodes/show-invisibles/"> Show invisibles: http://vimcasts.org/episodes/show-invisibles/

..and I have a :s/\v^[^\>]+\>\s//g substitution command which changes this line to:


As I understand the regular expression of this substitution, then ^[^\>]+\>\s part will match one or more whatever character(except >) from the beginning of the line until > and whitespace character appear. However, why is the \v needed? According to vim manual:


However, why is this needed in this particular case?

  • [^\>] means except '\' and '>', even with \v. – Antony Aug 5 '16 at 11:24

In this particular case, using \v doesn't make much difference


is perhaps cleaner than using the very magic modifier

Consider swapping two words:

s/\(\w\+\) \(\w\+\)/\2 \1/

With \v it is much cleaner and readable

s/\v(\w+) (\w+)/\2 \1/

So, it might be a habit to always use \v and it is closer to regular expression syntax used in perl, sed -r, awk etc

Your Answer

