Search code examples
cvimfolding

How to fold C code with vim?


I've been trying to explore code folding options in Vim, and I have stumbled upon this stack-overflow question. While I have been able to put that into my vimrc, the problem I'm having is that it doesn't fold the multi-line comments above a function. How do I solve this?


Solution

  • The default syntax/c.vim provides folding definitions. Unless you define a c_no_comment_fold variable, this also folds multi-line comments.

    To activate this, just put

    :setlocal foldmethod=syntax
    

    into ~/.vim/after/ftplugin/c.vim.