"set iskeyword-=_" not being set from vimrc
Asked Answered
K

6

11

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?

Kinsler answered 30/9, 2014 at 14:33 Comment(1)
Is it your vimrc or the default vimrc that you are not supposed to touch?Gyniatrics
R
12

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.

Ruffner answered 30/9, 2014 at 14:54 Comment(7)
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?Kinsler
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.Ruffner
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.Kinsler
Do you use sessions? Is something in your .viminfo that sets this?Ruffner
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 configKinsler
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?Emulate
@Emulate No; either turn off ftplugins completely, or undo via the after directory, as per ThomasH's answer.Ruffner
R
4

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.

Rus answered 6/12, 2016 at 16:8 Comment(1)
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.Methodist
C
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.

Cryan answered 31/8, 2016 at 0:0 Comment(0)
K
1

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

Kinsler answered 2/10, 2014 at 19:24 Comment(1)
i was able to solve it by just putting it towards the end of my .vimrcMoisesmoishe
F
1

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

autocmd BufReadPost *.conf set isk-=.
Fanchon answered 28/12, 2018 at 15:3 Comment(0)
B
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).

Bookrack answered 14/4, 2017 at 10:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.