In my vimrc, I have included a script (say, otherscript.vim, which I need to include for work reasons) that says:
autocmd FileType php setlocal iskeyword+=$
I like to avoid autocmds when I can and use the after
directory structure.
$ mkdir -p ~/.vim/after/{ftplugin,syntax,indent}
$ echo 'setlocal iskeyword-=$' >> ~/.vim/after/ftplugin/php.vim
This sets up a basic after
directory in your user-specific vim config folder. Whereas ~/.vim/ftplugin/$FILETYPE.vim
would be used in lieu of vim's standard $FILETYPE.vim file, files in an after
directory get executed after, allowing you to override or change the behavior of your ftplugins, syntax definitions, and indent commands.
As an additional example to show you how these work, I'll include part of my local after/syntax/python.vim
file here. I like all the "structural punctuation" of my code to stand out when I read it, so I do this:
syn match pythonParen /[()]/
syn match pythonBrack /[][]/
syn match pythonCurly /[{}]/
hi def link pythonParen Paren
hi def link pythonBrack Brack
hi def link pythonCurly Curly
I've also got an after/indent/php.vim
file that was supposed to fix some of the annoying indent issues I ran into with the indent behavior when switching in and out of <?php ?>
regions in a template file, but the code is a mess and never really worked in the first place, so I won't reproduce it here. I mention it only to give you an example of what can be done with the after hooks.