Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"set iskeyword-=_" not being set from vimrc

Basically the title. When I include in my vimrc

set iskeyword-=_

and save it, when I reload gvim and type

:set iskeyword

I still see

iskeyword=@,48-57,_,192-255

As you can see, the '_' is still there. If I just :set iskeyword-=_ it works as intended. Why doesn't this work from my vimrc? Is there an alternate way I can get around this and if so how?

like image 800
rockzombie2 Avatar asked Sep 30 '14 14:09

rockzombie2


4 Answers

I had the problem with a .conf file. So I did this in my .vimrc:

autocmd BufReadPost *.conf set isk-=.
like image 133
Nielas Aran Avatar answered Sep 22 '22 10:09

Nielas Aran


Check with :verbose set iskeyword? where this got set. Note that many filetype plugins change this value (but for a no-argument, plain Vim launch with an empty buffer, none should have been set).

If :verbose doesn't yield the answer, capture a full log of the Vim startup with vim -V20vimlog, and search for the option.

Also, is your .vimrc actually sourced? :scriptnames tells you.

like image 37
Ingo Karkat Avatar answered Oct 15 '22 06:10

Ingo Karkat


Overriding Global Plugin Settings from .vimrc

I had the same problem with settings coming from a global file type plugin (perl.vim in my case) where I wanted to change the iskeyword configuration in my .vimrc. Thanks to the hints in other answers I realized that the plugins are evaluated after my .vimrc, overriding changes I made.

The canonical answer to this situation is to create an "after" directory in your local configuration, like

~/.vim/after/ftplugin/perl.vim

and put the set iskeyword-=_ there. That solved it for me.

like image 3
ThomasH Avatar answered Oct 15 '22 07:10

ThomasH


Just reset the option in your .vimrc after plugins. According the documentation you can do it like this.

set iskeyword=@,48-57,192-255

@ - stands for all alphabetic letters
48-57 - stands for ASCII characters 48 to 57, which are the numbers 0-9
192-255 - are the printable latin characters

Happy coding.

like image 2
Arnold Gandarillas Avatar answered Oct 15 '22 07:10

Arnold Gandarillas