I know for searching a whole word I should use /\<mypattern\>. But this is not true for dash (+U002d) character and /\<-\> always fails. I also try /\<\%d45\> and it fails too. anyone know the reason?
Edit2: As @bobbogo mentioned dash is not in ‘iskeyword’ so I add :set isk+=- and /\<-\> works!
Edit1: I think in Vim /\<word\> only is valid for alphanumeric characters and we shouldn’t use it for punctuation characters (see Edit2). I should change my question and ask how we can search punctuation character as a whole world for example I want my search found the question mark in “a ? b” and patterns like “??” and “abc?” shouldn’t be valid.
\<matches the zero-width boundary between a non-word character and a word character. What is a word character? It’s specified by the isk option (:help isk).Since
-is not in your isk option, then-can never start a word, thus\<-will never match.I don’t know what you want, but
/\>-\<will match the dash inhello-word.