1

When using gvim 7.3, I can select a word by typing v and then w. The word selected does not include the punctuation after the word. When using vim 7.2 on Linux, selecting a word by typing v and then w also selects the following punctuation.

For example with this text and the cursor at the beginning of the line:
clk : in

On Windows, v w y o esc p produces
clk : in
clk 

On Linux, v w y o esc p produces
clk : in
clk :

Note the extra colon on Linux

Why is this? How can I make VIM on Linux behave like gvim on Windows (or vice-versa)?

2 Answers 2

1

vw will select the text from the cursor to the end of the current "word", where "word" is a sequence of characters from the set defined by the 'iskeyword' option. The 'iskeyword' option defaults to the set of ASCII alphanumeric characters plus underscore (_).

If vw is selecting more than that, then something, probably a filetype plugin, has added characters to 'iskeyword' to be, in the plugin author's opinion, more useful when editing the current file type. To find out where iskeyword is being set, execute

:verbose set iskeyword?

It may be that your Windows Vim installation has a different set of plugins than your Linux Vim installation, or that your Linux ~/.vimrc has filetype detection enabled and your Windows ~/_vimrc does not.

That behavior can be changed, but how it can or should be changed will depend on the behavior you want and how iskeyword is being set.

2
  • Thanks for answering. I checked iskeyword and it is the same on both systems. Looks like the default as you suggested.
    – nachum
    Nov 4, 2011 at 6:34
  • Did you check 'iskeyword' immediately after you observed the difference in behavior of w? The value of 'iskeyword' can change while you're using Vim because of the behavior of plugins. Another thing to try would be to start vim and gvim with the options -N -u NONE -i NONE and see if you still observe the difference in behavior of w.
    – garyjohn
    Nov 4, 2011 at 16:09
1

You can write viw to select an "inner word" (thats without the surrounding punctuation). viwoESCp would then produce the same output as your windows version.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .