Reputation: 8109
I can't find out how to search words with an exclamation mark at the end using boundaries.
p.e. text:
Do this!
search:
/\<this!\>
This doesn't match this!
in the text.
This either:
/\<this\!\>
I suppose that VIM thinks it must be Lookahead/Lookbehind Zero-Length Assertion.
How can I resolve this?
Upvotes: 3
Views: 1206
Reputation: 172520
The !
is not a keyword character (in your case, at least), so a regular expression assertion for a keyword to non-keyword boundary (which \>
is) won't match after it. What does work is this
/\<this\>!/
But here, the \>
is superfluous, as s
clearly is a keyword character, and !
isn't. So, only use the assertions where actually needed (like \<
at the beginning in your example, to avoid matching foothis!
), and all is well.
Alternatively, if for your purposes !
belongs to a word, and you want to match it as such, include it via
:setlocal iskeyword+=!
and use \k
for matching inside the word, e.g. \<\k\{5}\>
to find all 5-letter (key)words.
Upvotes: 4
Reputation: 4209
Try this (or replace \w
with the character class your words consist of):
/\<\w\+\!
The !
is not part of a word so any word boundary match like \>
will match before, not after.
Upvotes: 1