Last active
August 29, 2015 14:22
-
-
Save ossan-pg/c43b090b74b95e315273 to your computer and use it in GitHub Desktop.
Vim で C ファイル保存時に astyle でコードフォーマットする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! _DoAstyle() | |
" astyle でコードフォーマット実行 | |
exe ":!astyle %" | |
" フォーマット結果を反映 | |
exe ":e!" | |
" シンタックスハイライトが OFF になってしまうので強制 ON | |
syntax on | |
endfunction | |
command! DoAstyle call _DoAstyle() | |
augroup auto_astyle | |
autocmd! | |
autocmd BufWritePost *.[ch] :DoAstyle | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
■参考にしたとこ
人力検索はてな - vimで保存をしたときに、特定のコマンドを自動で実行できるようにしたいです。
http://q.hatena.ne.jp/1307276298