Setting Up Your .vimrc File for PHP Editing

Vim’s .vimrc is a config file, the beating heart of the program, and an essential step in getting Vim up and running. Using the .vimrc file, you can set up default settings for just about anything at all.


Vim usually comes with an example which you can copy to your home directory and edit with vim by issuing the following at the command line:

$ cp /usr/share/vim/vim70/vimrc_example.vim ~/.vimrc
$ cd ~
$ vim .vimrc

The .vimrc can not only contain basic config instructions, but also scripts. Here are a few useful settings I have found for editing PHP files:

set hlsearch -
Turns on the highlighted search function. You simply type ‘/’ followed by your search text and hit enter.

set nohls -Stops the word highlighting from sticking on longer than you need it to

set incsearch - Enables incremental searching - starts to search from first input character

set tabstop=4, set shiftwidth=4 - These are for getting Vim to set tabs and shift widths to PEAR standards

noremap :!php -l % - This maps -C to run the PHP parser and check the code you are editing

set showmatch - This setting highlights matching brackets while you are typing
syntax on - Finally, this turns on syntax highlighting - pretty colours if you like that sort of thing!

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blogmarks
  • co.mments
  • del.icio.us
  • digg
  • Fark
  • Furl
  • Reddit
  • Spurl
  • TailRank
  • YahooMyWeb

About this entry