Skip to content

Commit e93674b

Browse files
author
ma6174
committed
增加代码格式优化功能
1 parent 4d51386 commit e93674b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

.vimrc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,31 @@ func! Rungdb()
196196
endfunc
197197

198198

199+
"代码格式优化化
200+
201+
map <F6> :call FormartSrc()<CR>
202+
203+
"定义FormartSrc()
204+
func FormartSrc()
205+
exec "w"
206+
if &filetype == 'c'
207+
exec "!astyle --style=ansi --one-line=keep-statements -a --suffix=none %"
208+
elseif &filetype == 'cpp' || &filetype == 'hpp'
209+
exec "r !astyle --style=ansi --one-line=keep-statements -a --suffix=none %> /dev/null 2>&1"
210+
elseif &filetype == 'perl'
211+
exec "!astyle --style=gnu --suffix=none %"
212+
elseif &filetype == 'py'||&filetype == 'python'
213+
exec "r !autopep8 -i --aggressive %"
214+
elseif &filetype == 'java'
215+
exec "!astyle --style=java --suffix=none %"
216+
elseif &filetype == 'jsp'
217+
exec "!astyle --style=gnu --suffix=none %"
218+
elseif &filetype == 'xml'
219+
exec "!astyle --style=gnu --suffix=none %"
220+
endif
221+
exec "e! %"
222+
endfunc
223+
"结束定义FormartSrc
199224

200225

201226

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
- clone bundle 程序:`git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle`
1616
- 打开vim并执行bundle程序`:BundleInstall`
1717

18+
## 2013年5月18日更新
19+
20+
- 增加代码格式优化功能
21+
-`F6`可以格式化`C/C++/python/perl/java/jsp/xml/`代码
22+
- 需要安装以下软件:
23+
- `sudo easy_install -ZU autopep8`
24+
- `sudo apt-get install astyle`
25+
1826
## 2013年5月17日更新
1927

2028
- 增加高亮显示列功能

0 commit comments

Comments
 (0)