views:

494

answers:

3

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

+4  A: 

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.

Tomalak
Thanks Tomalak, I'll try that. Being lazy I was really hoping for something I wouldn't have to redo with every update of Vim though.
Ken
@Ken: you can do his suggestion in your own vim directory. never mess with the system's files
Jeremy Cantrell
+4  A: 

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

Luc Hermitte
A: 

Make a copy of your .vimrc, e.g. .vimrc.ref

Make the copy in another directory.

Then find out why the plugin authors really need to just clobber your .vimrc without:

  1. letting you know that they're clobbering it, and
  2. saving a copy of your .vimrc file so you can easily roll back.

Edit: And let http://www.vim.org/ know about those who would reach under your covers without letting you know!

HTH.

cheers,

Rob

Rob Wells
I don't think the plugin is altering his vimrc, I think he means that the plugin is changing the value of iskeyword, and adding back this character that he removed. When not editing PHP, iskeyword setting is fine.
rjray
rjray's interpretation is correct - the .vimrc isn't being altered, but the values are being changed by a plugin. Maybe overwritten is the wrong word to have used. Thank you for your contribution anyway!
Ken