Let's think big and look for a generic solution. IMHO, it is way
too restrictive to insist that a word is anything matching the pattern
/\k\+/ . I want a new option, 'wordpat', with a default value of
'\k\+', that specifies what should be recognized as a word, for purposes
of search patterns, Normal-mode commands such as w and b, and maybe
other uses. (Oh, yes: Insert-mode completion.)
Examples:
:let &l:wordpat = '\k\+\(-\k\+\)*'
In the general, I like it! In the implementation, I don't know
if there are snags that one will encounter. One might have to
include the cursor position to anchor it in the search text.
Funky conditions could occur if patterns contain certain atoms
(for better or worse). Could things like using \%<9c enforce
that words are only contained before column 9 (makes me think of
my cobol days)? Or even something like '\%>0l\%<42l\k*\%#\k*'
enforce that keywords are only found in the first 41 lines of
your file? Or can keywords only be duplicate-part words like
"mahimahi" using a pattern like '\(\k\+\)\1'? Or keywords are
only ever preceeded by "int" like 'int\_s\+\zs\k+'? Or alter the
behavior of the "*" and "#" commands to find the word that
*preceeds* the word under the cursor with something like
'\k\+\ze\K\+\k*\%#'
All these seem like sensible (for cases where "sensible" may be a
subset of as "pathological") potential use-cases for such a thing.
-tim