How to uncomment code block in emacs python-mode?
Asked Answered
C

4

10

I just started using python-mode in emacs and I noticed that while the major mode has an option for commenting out a region ((py-comment-region) which is bound (C-c #))there is no option to uncomment the code block which is already commented. I checked all the active keybinds in python-mode and could not find any relevant key. Am I missing something?

I did think of a couple of work arounds like using (delete-rectangular) (bound to C-x r d) to delete the comments. Another method would be to bind the (comment-or-uncomment-region) to some key and start using that.

But is there any option provided in python-mode itself by default?

Calcimine answered 12/9, 2012 at 5:26 Comment(0)
T
1

I'm using comment-dwim which is really smart and can be used for both commenting and un-commenting active regions. It works for the python mode as well.

You can find more information in emacs comment commands.

Teachin answered 12/9, 2012 at 6:12 Comment(0)
W
17

Not sure about your setup but I use M-; and it works for me.

Wilkins answered 19/8, 2013 at 21:57 Comment(0)
H
11

How to uncomment code block in emacs python-mode?

Select code, e.g. with Ctrl-Space to mark and cursor over desired code.

Then, meta-semicolon: Meta-;

That's escape then ;s or hold down Alt-;

The same method will also comment code.

Halliard answered 29/5, 2016 at 1:20 Comment(0)
A
2

Most comment region functions will uncomment a region with C-u comment-region-function

Anemology answered 17/9, 2012 at 9:59 Comment(1)
When I use C-u, emacs instantly changes the text selection to the beginning of the file to the first letter of my last selection.Subotica
T
1

I'm using comment-dwim which is really smart and can be used for both commenting and un-commenting active regions. It works for the python mode as well.

You can find more information in emacs comment commands.

Teachin answered 12/9, 2012 at 6:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.