[size=large]在 pydent 基础上 改造的
多了一些自动加空格,我是一个懒人,多一个空格都不高兴打。。。
还可以在 vim 一键排版
安装工具后,在.vimrc中加入下面代码,可以实现F12一键排版
map <F12> :call FormartSrc()<CR>
"定义FormartSrc()
func FormartSrc()
exec "w"
if &filetype == 'c'
exec "!astyle --style=ansi --one-line=keep-statements -a --suffix=none %"
elseif &filetype == 'cpp' || &filetype == 'hpp'
exec "r !astyle --style=ansi --one-line=keep-statements -a --suffix=none %> /dev/null 2>&1"
elseif &filetype == 'perl'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'py'||&filetype == 'python'
exec "r !pydent % > /dev/null 2>&1"
elseif &filetype == 'java'
exec "!astyle --style=java --suffix=none %"
elseif &filetype == 'jsp'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'xml'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'html'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'htm'
exec "!astyle --style=gnu --suffix=none %"
endif
exec "e! %"
endfunc
"结束定义FormartSrc
[/size]
多了一些自动加空格,我是一个懒人,多一个空格都不高兴打。。。
还可以在 vim 一键排版
安装工具后,在.vimrc中加入下面代码,可以实现F12一键排版
map <F12> :call FormartSrc()<CR>
"定义FormartSrc()
func FormartSrc()
exec "w"
if &filetype == 'c'
exec "!astyle --style=ansi --one-line=keep-statements -a --suffix=none %"
elseif &filetype == 'cpp' || &filetype == 'hpp'
exec "r !astyle --style=ansi --one-line=keep-statements -a --suffix=none %> /dev/null 2>&1"
elseif &filetype == 'perl'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'py'||&filetype == 'python'
exec "r !pydent % > /dev/null 2>&1"
elseif &filetype == 'java'
exec "!astyle --style=java --suffix=none %"
elseif &filetype == 'jsp'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'xml'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'html'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'htm'
exec "!astyle --style=gnu --suffix=none %"
endif
exec "e! %"
endfunc
"结束定义FormartSrc
[/size]