This page says that I can find duplicate words using a regular expression.

The suggested command is


What does "\w" mean here? Suppose the target pattern is "123\t123" where \t is the tab. Would the command be




1 Answer 1


:help /\w shows that \w is a regex metacharacter matching a word character -- any character that is either an underscore (_) or in the ranges 0-9, a-z, or A-Z.

The example regex is parsed as

\(        \)                Capture the match so it can be reused later
  \<    \>      \<  \>      Match (with zero-width) beginning/end of word
    \w\+                    Match one or more word characters
            \_s*            Match zero or more whitespace characters,
                              including newlines
                  \1        Match the same text as the first capture

This style of search is useful when you don't exactly know the contents of whatever is going to match inside the \( \).

Assuming that there's more possible variety in your suggested text to match (any 3-digit number, rather than just 123), you could use the style of regex as follows


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.