I have a lot of files with mixed HTML/PHP code.
Normally, Vim doesn't produce any indentation
of HTML parts. So I put in my ~/-vimrc:

============================================
" PHP
:let g:PHP_autoformatcomment = 0
autocmd FileType php set formatoptions=tcq textwidth=78 
:let g:PHP_BracesAtCodeLevel = 1 
map <C-B> :!php -l %<CR>

" PHP & HTML
if exists("b:did_indent")
  finish
endif
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+=<>>
==============================================

Do u thinf is it a good solution?
Are there better ones?
And have I to keep boot section "PHP and "PHP & HTML,
or only the second one?
Thanx
MS






-- 
Linux user no.: 353546
public key at http://keyserver.linux.it

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to