Often I need to search large xml mode files for the next occurrence of the word under the cursor but preferably not if it's a tag the closing tag
In the below example # is where the cursor is. Using *
or #
with iskeyword not including >
or <
will move between <Dealid>
and </Dealid>
.
<Deali#d>4444</Dealid>
... 50 lines
<Dealid>6666</Dealid>
... n lines
<Dealid>5643</Dealid>
I tried :set iskeyword+=<
which worked fine for moving to the next match but it changed vey
to include the <
of the closing tag so moving to the start of 6666
, for eg, and typing vey
will yank 6666<
rather than 6666
.
Anyway of getting the best of both words or limit the iskeyword+=<
to the *
and #
operators?
This should do what you want.
nnoremap * :set iskeyword+=<<CR>*:set iskeyword-=<<CR>
nnoremap # :set iskeyword+=<<CR>#:set iskeyword-=<<CR>
It sets changes iskeyword
before executing *
or #
and then resets it.