1. install full vim with plugins.
put following vim commands in /root/.vimrc
:set nocompatible
:filetype indent on
:syntax on
:set tabstop=4
:set shiftwidth=4
:set expandtab
2. create a vim script file (lets say vimscript.scr) in /root
put the following vim commands in vimscript.scr file
" this is a vim script comment
" remove \r in case file is from windows world
:%s/\r$//g
" set filetype as javascript and indent it
:set ft=javascript
gg=G
" set filetype as html and indent it
:set ft=html
gg=G
" set filetype as php and indent it
:set ft=php
gg=G
" convert multiple blank lines to single blank line
:%s/\n\{3,}/\r\r/e
" after indenting save file
:wq
" script end
3. to indent all php files in a dir, go to that dir and run
#find . -type f -name '*.php' -exec vim -s /root/vimscript.scr "{}" \;
No comments:
Post a Comment