Searched this a bit before asking. There is another thread that seems to be asking about this same issue in the IDLE editor, but I'm wondering about TextWrangler.
The manual lists "Un/Comment Selection" but in the keyboard shortcut section it doesn't seem to appear, and it's certainly not under my "Text" dropdown when I'm editing a Python file. (I briefly checked other languages and still did not see the option in the dropdown.)
Is there some way to handle this or add the feature for Python? If there is some comprehensive guide to using TextWrangler with Python (or if you want to pimp any other editor for OS X besides the tired old emacs/vim, let me know.)
Thanks
The most common way to comment out a block of code in Python is using the # character. Any line of code starting with # in Python is treated as a comment and gets ignored by the compiler.
For python code, the "comment block" command Alt + Shift + A actually wraps the selected text in a multiline string, whereas Ctrl + / is the way to toggle any type of comment (including a "block" comment as asked here). You can find the comment options in the Edit menu if you forget the keyboard shortcuts.
Using triple-quoted string literals Another way to add multiline comments is to use triple-quoted, multi-line strings. These strings are to be used carefully and should not be confused with Docstrings (triple-quoted string literals appearing right after a function/class/module to generate documentation).
It's in the "Text" menu (5th entry). The command doesn't have a keyboard shortcut by default, but you should be able to add one with the system's keyboard preferences.
Exact instructions for adding block comment shortcut for TextWrangler:
Add
-- There you go
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With