パーソナルツール

フォールディングを設定して、コードの見通しを良くする

作者: 小見 拓 最終変更 2012年01月08日 12時07分

フォールディングを設定して、コードの見通しを良くする

モードラインで「foldmethod=marker」を指定する

スクリプトの上端か下端に、 「foldmethod=marker」を指定するモードラインを定義する。

" vim: foldmethod=marker :

折りたたみ箇所を指定する。

  • 指定範囲を折りたたむ
"{{{
:somecode1
:somecode2
:somecode3
:somecode4
"}}}
  • ファンクションを折りたたむ
:function! SimpleFunction() "{{{
    :return "SimpleFunction() is called."
:endfunction
"}}}
  • autocmdのグループを折りたたむ
:augroup Head "{{{
    :autocmd!
    :execute ":autocmd BufReadCmd   head" .s:spc. "*,head" .s:spc. "*/* HeadRead  <afile>"
    :execute ":autocmd FileReadCmd  head" .s:spc. "*,head" .s:spc. "*/* HeadRead  <afile>"
    :execute ":autocmd BufWriteCmd  head" .s:spc. "*,head" .s:spc. "*/* HeadWrite <afile>"
    :execute ":autocmd FileWriteCmd head" .s:spc. "*,head" .s:spc. "*/* HeadWrite <afile>"
:augroup END
"}}}
  • スクリプト中のコメントや説明を折りたたむ。
" このファンクションは・・・ "{{{
" という処理を行っています。
" 引数1:・・・・・
" 引数2:・・・・・
" 引数3:・・・・・
"}}}
ドキュメントアクション
コメント
blog comments powered by Disqus