Vim move word skips dot

8

4

I'm using MacVim with spf13 and when I use w to move a word forward, dots are seen as part of the word.

     myObject.myMethod()
     ^       ^        ^
     |       |        |
cursor       |        |
             |        |
  where I want to go  |
                      |
where I'm actually moved

Is there a setting for this?

Follow-up: I noticed that vim only behaved like this with some files. For fileA.coffee moving forward skips the dots, but for fileB.coffee it does not. Is this set on file level somehow?

However, on the files that skips the dot (fileA) doing :set iskeyword-=. as suggested by Heptite works.

Cotten

Posted 2014-04-14T07:06:45.043

Reputation: 499

Answers

10

It's the 'iskeyword' option. You may be able to change this behavior simply by doing:

:set iskeyword-=.

If that doesn't work it means the period character is included in the option as part of a character range instead of individually, and you'll have to check the value (with the question mark as part of the command):

:verbose set iskeyword?

Then determine how to properly modify it to exclude the period. Take a look at this (with the single-quotes as part of the command):

:help 'iskeyword'

I should warn you that having the period character included in 'iskeyword' is not a Vim default, so you may have a filetype plugin or language specific syntax highlighting that is adding it. The reason it would is because the 'iskeyword' is used for many things, including certain regular expression atoms, which can be used in syntax highlighting. So removing it may "break" something else.

Heptite

Posted 2014-04-14T07:06:45.043

Reputation: 16 267

:set iskeyword-=. worked. Though, I posted a follow-up question.. – Cotten – 2014-04-14T07:29:11.180

3@Cotten: As my answer says, though apparently not clearly enough, yes this option can be and probably has been set on a per-buffer level, likely by a system syntax highlighting script, or a filetype plugin. The ":verbose set iskeyword?" command in my answer will tell you which sourced script set it. – Heptite – 2014-04-14T21:57:15.990

@Heptitie thanks for clarification around per-buffer level and it probably being set by a script or plugin! – Cotten – 2014-04-15T08:13:10.850

0

Right way is change iskeyword definition.

I use on vimrc:

set iskeyword=65-90,95,97-122,48-57 "the same: a-z,_,A-Z,0-9

If you use some plugins, like ctrlp, you need some extra work to keep iskeyword configuration active, because exist a lot of plugins change iskeyword each time they execute.

You can map leader+k to run this command

map <leader>k :set iskeyword=65-90,95,97-122,48-57<CR>

Steven Koch

Posted 2014-04-14T07:06:45.043

Reputation: 101

0

i've had many issues from neocomplete plugin that was added to spf13. Completion failed in many cases, searches are failing, and even ESC doesn't work within words to go back to normal mode. Removing neocomplete and all settings related to neocomplete resolved most of these issues, although ESC is still required twice in certain situations to get out of Insert mode.

MKouhosei

Posted 2014-04-14T07:06:45.043

Reputation: 1

Instead of neocomplete you can use YCM it worth

– Arnold Gandarillas – 2016-08-30T23:34:36.400

I've upgraded to SpaceVim. Happy now :) – MKouhosei – 2018-05-06T19:34:28.723