0

In python mode (the one that Emacs uses to open python script by default), can I fold the definition of a function?

How can I quickly select the entire definition of a function? (so that I can copy and paste)

If not, which python package/IDE shall I install in emacs? Thanks.

3

For folding, I use Hideshow mode (built-in) with Hydra like this:

(global-set-key
 (kbd "M-F")
 (defhydra hydra-fold (global-map "M-F")
   "Fold"
   ("h" hs-hide-all "hide all")
   ("s" hs-show-all "show all")
   ("f" hs-toggle-hiding "toggle")))

To mark the current function, press C-M-h to run mark-defun.

These work for nearly any language.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.