Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I stop settings in vimrc from being overwritten by plugins?

Tags:

php

vim

plugins

This question follows on from this vim search question

I have a setting in my .vimrc which excludes $ as a valid part of a word:

set iskeyword-=$

This works fine for most files but isn't working in PHP. I assume it is being overwritten by a php plugin, but since plugins are loaded after .vimrc I can't work out how to overwrite this setting. I'd prefer not to have to type

:set isk-=$ 

every time I load a PHP file.

Any suggestions?

( Ubuntu 8.04 / Vim 7.1.138 if it matters )

Summary

Two excellent answers, thank you!

I went with tomalak's because it was less effort, and added the following to my ~/.vimrc

autocmd FileType php setlocal isk-=$

but thanks also to Luc Hermitte. Putting the settings in a ~/vim/after/ftplugin/php.vim file also worked.

:help autocmd and :help after-directory both helped too

like image 518
Ken Avatar asked Nov 20 '08 15:11

Ken


2 Answers

Add a {rtp}/after/ftplugin/php.vim that contains the :setlocal isk-=$

Otherwise, you will have to track where it has been changed last with :verbose set isk, or by playing with :scriptnames

like image 197
Luc Hermitte Avatar answered Oct 31 '22 20:10

Luc Hermitte


I would probably just add set isk-=$ to my syntax highlighting auto command in $VIMRUNTIME\filetype.vim. Don't know if it is the nicest way to do it, though.

Thinking about it... I think it would be enough to have an appropriate autocommand in your vimrc.

au   FileType php    set isk-=$

This executes after the FileType has been set. Auto commands are executed in the order they are given, so when you put it late in your vimrc it will execute last for PHP files.

like image 41
Tomalak Avatar answered Oct 31 '22 20:10

Tomalak