From Sum-e Wiki
map M :%s/^M//g
syntax on
set ts=4
map ,, F4r$A
" Better indent support for PHP by making it possible to indent HTML sections
" " as well.
if exists("b:did_indent")
finish
endif
" This script pulls in the default indent/php.vim with the :runtime
" command
" which could re-run this script recursively unless we catch that:
if exists('s:doing_indent_inits')
finish
endif
let s:doing_indent_inits = 1
runtime! indent/html.vim
unlet b:did_indent
runtime! indent/php.vim
unlet s:doing_indent_inits
function! GetPhpHtmlIndent(lnum)
if exists('*HtmlIndent')
let html_ind = HtmlIndent()
else
let html_ind = HtmlIndentGet(a:lnum)
endif
let php_ind = GetPhpIndent()
" priority one for php indent script
if php_ind > -1
return php_ind
endif
if html_ind > -1
if getline(a:num) =~ "^<?" && (0< searchpair('<?', '', '?>', 'nWb')
\ || 0 < searchpair('<?', '', '?>', 'nW'))
return -1
endif
return html_ind
endif
return -1
endfunction
setlocal indentexpr=GetPhpHtmlIndent(v:lnum)
setlocal indentkeys+=<>>
function! PHPsynCHK()
let winnum =winnr() " get current window number
silent make -l %
cw " open the error window if it contains error
" return to the window with cursor set on the line of the first error
" (if any)
execute winnum . "wincmd w"
endfunction
:setl makeprg=php
:set errorformat=%m\ in\ %f\ on\ line\ %l
" Map <CTRL>-P to check the file for syntax
:noremap <C-P> :call PHPsynCHK()<CR>