I live in Vim, but finally got tired of editing my .module files without syntax highlighting - ugh. Turns out all you have to do is tell vim what the file is so that it knows what to shade.
Make sure that the following is in your vimrc file - notice the filetype on line:
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
filetype on
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endifThen place the following in ~/.vim/filetype.vim, restart Vim and you are all set!
" ~/.vim/filetype.vim
" tell Vim what a .module file is
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufRead,BufNewFile *.module setfiletype php
augroup END
See also!
Hi Kevin!
For more great vim things, I think also the simpler way to do this, see also
http://phpslacker.com/2009/02/05/vim-tips-for-php-programmers/
and Drupal.org's own Configuring vim.
Meantime I try to keep Vim as PHP IDE and another page on vim configuration up to date with code and links on agaric...
benjamin, Agaric
More files ...
I have had this config in ~/.vim/filetype.vim for a long time:
It handles all Drupal file types that are essentially PHP or similar.
" File typesif exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufRead,BufNewFile *.php,*.module,*.theme,*.inc,*.install,*.info,*.engine,*.profile,*.test setfiletype php
augroup END
For gvim I use filetype plugin on
That way, I can get support for a variety of languages.
Here is my .vimrc (for ruby, python and php):
set expandtab
set tabstop=2 shiftwidth=2 softtabstop=2
set autoindent
set nocompatible
syntax on
filetype on
filetype indent on
filetype plugin on
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
if has("autocmd")
augroup php
autocmd BufRead *.inc set filetype=php
autocmd BufRead *.module set filetype=php
augroup END
endif
I also have a module.vim and a php.vim in $HOME/.vim/after/ftplugin
module.vim:
:colo sea
set expandtab
set tabstop=2 shiftwidth=2 softtabstop=2
set autoindent
set foldmethod=indent
set filetype=php
php.vim:
:colo sea
set expandtab
set tabstop=2 shiftwidth=2 softtabstop=2
set autoindent
set foldmethod=indent
(got the colorschemes *.vim files installed in $HOME/vim/colors)
Victor Kane
http://awebfactory.com.ar
This is what I use and works
This is what I use and works well enough:
~ Singh$ cat .vimrcau BufRead,BufNewFile *.module set filetype=phpsyntax on
--
Gurpartap Singh -- http://gurpartap.com
Post new comment