Zach_is_my_name
Zach_is_my_name

Reputation: 60

Does VIM definition of 'inner-word' change based upon context?

I'm trying to figure out why the same key pattern viw appears to behave differently in separate contexts

I have two buffers where the cursor is [ ]

In one a javascript file:

import {[f]oo, bang} from './utilities'

visual selection: foo

The other, :help

"inner word", select [count] words (see |word|).
White space between words is counted too.
When used in Visual linewise mode "iw" switches to
Visual characterwise [m]ode.

visual selection: mode.

I'm confused why in the first the inner-word excludes the punctuation character comma , and the second includes the punctuation .

What accounts for this inconsistency?

Upvotes: 0

Views: 309

Answers (1)

B.G.
B.G.

Reputation: 6026

Yes (well not technically, the definition does not change, because it is per definition variable). Vim is (if configured to be) filetype sensitive. see :h filetype. So EVERY setting can be different in a different filetype.

The one you are looking for is iskeyword. This controlls which characters are word boundaries. :h iskeyword states:

For a help file it is set to all non-blank printable characters except '*', '"' and '|' (so that CTRL-] on a command finds the help for that command).

So . belongs to the word, like a-z

Upvotes: 1

Related Questions