Closed learner010 closed 5 years ago
You should have a look hs-minor-mode.
EDIT: Here is a quick setup and demo:
(add-hook 'prog-mode-hook 'hs-minor-mode)
Then, in your source file above, press C-c @ C-l
to hide all methods. Press C-c @ C-M-s
again to show all methods.
If you want to hide a specific level, add a prefix argument before C-c @ C-l
. For example, press C-u 2 C-c @ C-l
will hide blocks that are two levels below current block.
@tuhdo Following ur suggestion, I added following configuration to my personal config.el.
(defun hide-level-1 ()
(interactive)
(hs-hide-level 1))
(defun hide-level-2 ()
(interactive)
(hs-hide-level 2))
(defun hide-level-3 ()
(interactive)
(hs-hide-level 3))
(evil-leader/set-key "f1" 'hide-level-1)
(evil-leader/set-key "f2" 'hide-level-2)
(evil-leader/set-key "f3" 'hide-level-3)
The problem is, when I press ,f2
the python code folds in alternative manner. Something like below:
class AClass:
def a_method(self): ...
def b_method(self):
pass
def c_method(self): ...
def c_method(self):
pass
It works fine for lisp and javascript but in python.
I can also confirm this. A workaround was suggested here:
http://emacs.stackexchange.com/questions/18381/hideshow-with-python-hiding-only-one-part
which is unfortunately not using the hs-* functions to do the folding.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!
This issues been automatically closed due to lack of activity. Feel free to re-open it if you ever come back to it.
Before Emacs I used Vim. In my Vim configuration file I had following key maps for folding (taken from http://vim.spf13.com/). The folding is based upon indent level.