Re: [PHP-DOC] Contribution to new HOWTO - editing w/ VIM From: Daniel Beckham (danbeck <email protected>)
Date: 08/28/00

That was me.. thanks for the input. I've got a rough draft of the outline
and I'll work a VIM section into it shortly. Once I have a more complete
draft, I hope to put it up on a public CVS so that people can help keep it
updated. I'll keep you posted.

Daniel

----- Original Message -----
From: "Jesus Castagnetto" <jmcastagnetto <email protected>>
To: "PHPDOC" <phpdoc <email protected>>
Sent: Monday, August 28, 2000 4:52 PM
Subject: [PHP-DOC] Contribution to new HOWTO - editing w/ VIM

> [The first time I sent this I forgot to put a subject and it never
> appeared on the list]
>
>
> Some days ago someone in the list was mentioning that he/she was
> working on a new HOWTO for phpdoc. I use VIM for editing the XML and
> would like to contribute the settings I found helpful:
>
> --- included text from my .vimrc
>
> set ts=4
> set sw=4
> set ai
> set tw=78
> set bs=2
> set expandtab
> auto BufReadPost *.xml retab! 4
> auto BufWritePre *.xml retab! 4
> auto BufWritePost *.xml retab! 4
> auto BufNewFile *.xml set ts=4
>
> " The functions below are not critical for XML, just useful in gral.
> "
> " define my XML/HTML tag creation function
> " pass a second parameter to set the number of tabs to use for
> indenting
> function! Xmltag (tagname, ...)
> let tabx = ''
> if a:0 > 0
> let ix = 0
> while ix < a:1
> let tabx = tabx . "\t"
> let ix = ix + 1
> endwhile
> endif
> call append(line(".") + 0, tabx . "<" . a:tagname . ">")
> call append(line(".") + 1, tabx . "\t" . "CONTENT_HERE")
> call append(line(".") + 2, tabx . "</" . a:tagname . ">")
> /CONTENT_HERE
> endfunction
>
> " define the user command "Z" when editing XML/HTML
> au BufNewFile,BufRead *.html,*.xml command! -nargs=+ Z call
> Xmltag(<f-args>)
>
> " execute command in all the files that were loaded into vim
> function! DoAllList (command)
> let i = 0
> while i < argc()
> if filereadable(argv(i))
> execute "e ".argv(i)
> execute a:command
> endif
> let i = i + 1
> endwhile
> endfunction
>
> " execute command in all the loaded buffers
> function! DoAllBuffers (command)
> let i = 1
> let lastbuff = bufnr("$")
> let current = bufnr("%")
> execute "brewind"
> while i <= lastbuff
> if bufexists(i)
> execute "b ".i
> execute a:command
> endif
> let i = i + 1
> endwhile
> execute "b ".current
> execute "wa"
> endfunction
>
> " example: DoAll %s/^> //ge
> command! -nargs=+ -complete=command DoAll call DoAllBuffers(<q-args>)
> command! -nargs=+ -complete=command DoList call DoAllList(<q-args>)
>
> " use DoAllList to execute a simple string search and replace
> " in all loaded files (named in the command line arguments)
> function! ReplaceAllList (origstr, newstr)
> let replace = '%s/'.a:origstr.'/'.a:newstr.'/ge|update'
> echo "Replacing ".a:origstr." with ".a:newstr." in all loaded files"
> call DoAllList (replace)
> endfunction
>
> " use DoAllBuffers to execute a simple string search and replace
> " in all loaded buffers
> function! ReplaceAllBuffers (origstr, newstr)
> let replace = '%s/'.a:origstr.'/'.a:newstr.'/ge'
> echo "Replacing ".a:origstr." with ".a:newstr." in all loaded
> buffers"
> call DoAllBuffers (replace)
> endfunction
>
> " example: ReplaceAll append prepend
> command! -nargs=1 ReplaceAll call ReplaceAllBuffers(<f-args>)
> command! -nargs=1 ReplaceList call ReplaceAllList(<f-args>)
>
> --- end of included text ---
>
> The settings before the function definition part are the more useful
> for the XMLs we are using when writing DocBook. Most of those (except
> for the retab I think) could be put in a modeline (see ":help
> modeline" in vim if you want more info) in the XML files if people
> want that instead (similar to the ones for emacs' psgml mode):
>
> <!-- vim: set ts=4 sw=4 tw=78 bs=2 ai et: -->
>
> Folding is not finished in VIM.
>
> =====
> Jesus M. Castagnetto - jmcastagnetto <email protected>
> "Jikishin kore dojo nari" (Zen saying)
> "Life is, ask no more" (me :)
> PalmPilot stuff & etc.:
> http://www.geocities.com/jm_castagnetto/
> LAB: http://www.scripps.edu/research/metallo
> Metalloprotein DB: http://metallo.scripps.edu/
>
>
> -------------------------------------------------
> Created by Zkey.com - http://www.zkey.com
> Awarded PCMagazine's Editors' Choice
>