Skip to content

Commit

Permalink
增加代码格式优化功能
Browse files Browse the repository at this point in the history
  • Loading branch information
ma6174 committed May 18, 2013
1 parent 4d51386 commit e93674b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,31 @@ func! Rungdb()
endfunc


"代码格式优化化

map <F6> :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 !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



Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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日更新

- 增加高亮显示列功能
Expand Down

0 comments on commit e93674b

Please sign in to comment.