10

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?

rockzombie2
  • 2,835
  • 4
  • 16
  • 20

6 Answers6

11

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.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • My _vimrc is sourced, and it looks like it was last set from ~\vim\vim74\autoload\netrw.vim. This seems to change though. How do I see what the options are for `vim -V20vimlog`? – rockzombie2 Sep 30 '14 at 21:22
  • After quitting Vim, you should have a file `vimlog` in your current directory. It contains all commands executed during the Vim session. Search for `iskeyword` (or `isk`) in there. – Ingo Karkat Oct 01 '14 at 06:18
  • The only instance of `isk` or `iskeyword` that I see in the log is where it sources my `_vimrc`. I even added an extra line (`set iskeyworkd+=/)` to see if it picked up on it (which it did) but it still doesn't look like it changed when I check with `set iskeyword`. – rockzombie2 Oct 01 '14 at 14:53
  • Do you use sessions? Is something in your `.viminfo` that sets this? – Ingo Karkat Oct 01 '14 at 15:25
  • I don't know about my `.viminfo` but in my config file I do have this: `" Persistent Undo ~ Not sure if this works " Keep undo history across sessions, by storing in file if has('persistent_undo') silent !mkdir ~/.vim/backups > /dev/null 2>&1 set undodir=~/.vim/backups set undofile endif` That's the only thing regarding sessions in my config – rockzombie2 Oct 01 '14 at 15:56
  • Found out my `iskeyword-=-` gets overwritten from various ftplugins (tried it with .vim and .slim files and both ftplugins overwrite it). Is there a way to set `iskeyword` globally, so it takes precedence over any ftplugin? – cseelus Jan 23 '18 at 20:45
  • 1
    @cseelus No; either turn off ftplugins completely, or undo via the after directory, as per ThomasH's answer. – Ingo Karkat Jan 23 '18 at 20:57
3

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.

ThomasH
  • 22,276
  • 13
  • 61
  • 62
  • Why are core config options hidden down here where you can't override them in the .vimrc? R is hiding their damaging config options that break code here, where you need experience in low level core vim hacking to fix. Adding config options to ftplugin fixed it, why are things unrelated to ftp put here? Is this systematic obfuscation? What's next? Default config options that spins the viewpane upside down so you have to edit .so objects in C and recompile from src to fix? This is insane. it's like buying a car and having to rewire the radio so the gas pedal doesn't honk the horn. – Eric Leschinski Apr 15 '17 at 17:59
2

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.

Arnold Gandarillas
  • 3,896
  • 1
  • 30
  • 36
1

Found it: in my _vimrc, at the bottom there was two other files getting sourced. I just removed them and it worked!

rockzombie2
  • 2,835
  • 4
  • 16
  • 20
  • i was able to solve it by just putting it towards the end of my .vimrc –  Apr 23 '19 at 23:49
1

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

autocmd BufReadPost *.conf set isk-=.
Luc PHAN
  • 316
  • 2
  • 13
0

In a comment in vim80/ftplugin/perl.vim it says:

" The following line changes a global variable but is necessary to make
" gf and similar commands work.  The change to iskeyword was incorrect.
" Thanks to Andrew Pimlott for pointing out the problem. If this causes a
" problem for you, add an after/ftplugin/perl.vim file that contains
"       set isfname-=:
set isfname+=:
set iskeyword+=:

This speaks of changing back isfname, but obviously set iskeyword-=_ can be added in that file (as well).

Coroos
  • 371
  • 2
  • 9