From e93674b089be4b6411cdda607d34152e33a95adb Mon Sep 17 00:00:00 2001 From: ma6174 Date: Sat, 18 May 2013 17:56:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=A0=81=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vimrc | 25 +++++++++++++++++++++++++ README.md | 8 ++++++++ 2 files changed, 33 insertions(+) diff --git a/.vimrc b/.vimrc index 7b272f27..ddbc0497 100755 --- a/.vimrc +++ b/.vimrc @@ -196,6 +196,31 @@ func! Rungdb() endfunc +"代码格式优化化 + +map :call FormartSrc() + +"定义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 !autopep8 -i --aggressive %" + 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 %" + endif + exec "e! %" +endfunc +"结束定义FormartSrc diff --git a/README.md b/README.md index 0cb5d303..0a3ac744 100755 --- a/README.md +++ b/README.md @@ -15,6 +15,14 @@ - clone bundle 程序:`git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle` - 打开vim并执行bundle程序`:BundleInstall` +## 2013年5月18日更新 + +- 增加代码格式优化功能 +- 按`F6`可以格式化`C/C++/python/perl/java/jsp/xml/`代码 +- 需要安装以下软件: + - `sudo easy_install -ZU autopep8` + - `sudo apt-get install astyle` + ## 2013年5月17日更新 - 增加高亮显示列功能