Skip to content

Instantly share code, notes, and snippets.

@ossan-pg
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ossan-pg/c43b090b74b95e315273 to your computer and use it in GitHub Desktop.
Save ossan-pg/c43b090b74b95e315273 to your computer and use it in GitHub Desktop.
Vim で C ファイル保存時に astyle でコードフォーマットする
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
@ossan-pg
Copy link
Author

ossan-pg commented Jun 6, 2015

■参考にしたとこ
人力検索はてな - vimで保存をしたときに、特定のコマンドを自動で実行できるようにしたいです。
http://q.hatena.ne.jp/1307276298

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment