I know the thread about having folds for LaTex. However, I want folds for C++/Java when I code.
How can you have either automatic or manual folds in Emacs for C++/Java?
I know the thread about having folds for LaTex. However, I want folds for C++/Java when I code.
How can you have either automatic or manual folds in Emacs for C++/Java?
Make sure you have folding-mode.el. Then, insert
// {{{
// }}}
Around your code. Reload your buffer, and voila! You'll have folds.
You can use CEDET to do this. This package provides global-semantic-tag-folding-mode, that allows to fold functions, classes/structures, comments, namespaces, etc. It works more properly than other packages, as it has all syntactic information about code.
There is introduction article about CEDET, that allows to quickly start work with it
For Java, use JDEE. For C/C++ see the other answer about CEDET.
My customization for hs-minor-mode is as follows
(add-hook 'c-mode-common-hook
(lambda()
(local-set-key (kbd "C-c <right>") 'hs-show-block)
(local-set-key (kbd "C-c <left>") 'hs-hide-block)
(local-set-key (kbd "C-c <up>") 'hs-hide-all)
(local-set-key (kbd "C-c <down>") 'hs-show-all)
(hs-minor-mode t)))
You could experiment with selective-display. It's more of a quick folding of all your code according to its indentation level. It's great for getting class/function summaries or for moving around quickly.
But if folding up blocks of code is what you want, then HideShow, like Arkadiy pointed out, is probably more suitable.