Search code examples
c++editorcommentsfolding

Hide Comments in Code in Unix Environment


I work in a Unix environment with the typical Unix tools (emacs, vim, gvim, sunstudio, etc)

My project has huge gross boilerplate comments on every method. It makes the files thousands of lines long, with a couple hundred lines of actual code. I may be exagerrating a bit but you get the idea. I am looking for a way when viewing these files to hide (not remove) all comments so I can quickly go through the code. C++ comments '//' only.


Solution

  • It all depends on which editor you use. In vim, you can enable folding with :

    set foldenable
    

    Then, you'll be able to use different of folding methods, for mainstream languages, you can set :

    set foldmethod=syntax
    

    which will enable syntax folding.

    There are half a dozen folding methods, I think the best would be to read

    help folding
    

    which should answer everything.