I am using the latest version of Gvim on Windows 10.

When I type / and some expression, for example /a, I see all matches in the document highlighted.

The documentation says that the asterisk symbol * will match repeated occurrences of the same character, for example, *n will match nnnn.

However, when I type /*n or /\*n, nothing is highlighted, and when I press enter, I receive the message "Pattern not found", even though the word "Connect" is in the document.

When I enter /n*, the entire document is highlighted.

Does this indicate the asterisk has had its meaning remapped due to some Windows configuration or is there some other reason I am not able to match repeated instances of characters? What can I do about this?

1 Answer 1

  1. The question is basically about (standard) regex, not Vim.
  2. Quantifier, such as an asterisk, applies to what it follows, not what it precedes, i.e. n*, not *n.
  3. The asterisk means "zero or more". Hence n* matches just anything. It should probably be nn* or n\+ instead.
  • Aha. Thank you very much.
    – John Smith
    Sep 10, 2021 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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