From aaf3d478b27e426c5828b530ef3778742ca51ebc Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Wed, 17 Oct 2001 19:18:08 +0000 Subject: [PATCH] Add information for using vim to format files for phpgroupware. --- phpgwapi/doc/vim.format | 98 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 phpgwapi/doc/vim.format diff --git a/phpgwapi/doc/vim.format b/phpgwapi/doc/vim.format new file mode 100644 index 0000000000..adb6a90813 --- /dev/null +++ b/phpgwapi/doc/vim.format @@ -0,0 +1,98 @@ +VIM 6.0: + +The following should be helpful in making sure your code adheres to +our required format. This should turn on indenting and syntax +highlighting for .php files in vim. + +Add the following to your ~/.vimrc: + +set ts=4 +filetype on +filetype indent on +set sw=4 +set smarttab + + +Place the following into, e.g., /usr/share/vim/vim60/indent/php.vim. +This is not a vim syntax file, so don't overwrite your syntax/php.vim +with this: + +----CUT HERE---- +" Vim indent file +" Language: Php +" Author: Miles Lott +" URL: http://milosch.dyndns.org/php.vim +" Last Change: 2001 Sep 08 + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal indentexpr=GetPhpIndent() +setlocal indentkeys+=0=,0),=EO + +" Only define the function once. +if exists("*GetPhpIndent") + finish +endif + +function GetPhpIndent() + " Get the line to be indented + let cline = getline(v:lnum) + + " Find a non-blank line above the current line. + let lnum = prevnonblank(v:lnum - 1) + " Hit the start of the file, use zero indent. + if lnum == 0 + return 0 + endif + let line = getline(lnum) + let ind = indent(lnum) + + " Indent after php open tags + if line =~ ']' + let ind = ind - &sw + endif + + " Indent blocks enclosed by {} or () + if line =~ '[{(]\s*\(#[^)}]*\)\=$' + let ind = ind + &sw + endif + if cline =~ '^\s*[)}]' + let ind = ind - &sw + endif + + return ind +endfunction +----CUT HERE---- + + +HINT: To reformat an already-coded file using the above: + +1. Format the first few lines of the file manually +