0

I want to set the following matchpairs option in vim only if filetype is PHP.

set matchpairs+==:;

Is it possible to do it?

I tried to read the documentation for matchpairs but it doesn't seem to mention any such option.

Sudar
  • 18,954
  • 30
  • 85
  • 131

2 Answers2

3

The best way to customize settings by filetype is using droping a file into your ftplugin folder of your runtime folder. Normally ~/.vim/ftplugin

The file must be named as the file type, so if you were doing this for Ruby, you would have ~/.vim/ftplugin/ruby.vim

Just make sure that your have support for filetypes

:filetype plugin on

And! Maybe instead of using set commands, you will want to use setlocal so the effects stays only within the current buffer.

SystematicFrank
  • 16,555
  • 7
  • 56
  • 102
2

Add this to your .vimrc:
autocmd FileType php setlocal matchpairs+==:;

But if you have more settings you want to set for a specific filetype, you should save them in ~/.vim/ftplugin/YOUR_LANGUAGE.vim (without the autocmd FileType YOUR_LANGUAGE prefix).

miu
  • 1,234
  • 2
  • 18
  • 34
  • Since it is appending to `matchpairs` setting, will the `matchpairs` setting be removed if I switch to a new file of different filetype? – Sudar Sep 08 '14 at 06:02