Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to uncomment code block in emacs python-mode?

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?

like image 950
Pulimon Avatar asked Sep 12 '12 05:09

Pulimon


2 Answers

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.

like image 165
Russia Must Remove Putin Avatar answered Oct 02 '22 08:10

Russia Must Remove Putin


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

like image 37
LWZ Avatar answered Oct 02 '22 08:10

LWZ