Home Download Buy Blog Forum Support

Is there a way to comment out multiple lines?

Is there a way to comment out multiple lines?

Postby aple on Mon Sep 05, 2011 2:24 am

For instance, if I wanted to take this:
Code: Select all
x = 1
print("x is {}.").format(x)

y = 2
print("y is {}.").format(y)

Then highlight the bottom 2 lines and turn it to this:
Code: Select all
x = 1
print("x is {}.").format(x)

# y = 2
# print("y is {}.").format(y)


I'm sure there is an easy way to do this (as ST has thought of everything), but I can't seem to find it.
aple
 
Posts: 42
Joined: Fri Aug 19, 2011 12:42 pm

Re: Is there a way to comment out multiple lines?

Postby aple on Mon Sep 05, 2011 2:26 am

Nevermind. I'm an idiot. Just found it under "Edit > Comments".

For those interested, the shortcut is Ctrl + \ and it works perfect.

Edit: I am actually kinda curious what "Toggle Block Comment" does though.
aple
 
Posts: 42
Joined: Fri Aug 19, 2011 12:42 pm

Re: Is there a way to comment out multiple lines?

Postby atomi on Mon Sep 05, 2011 4:08 am

Both of those key bindings are set to the same command: toggle_comment.
Unless you've overriden the key binding, they should both do exactly the same thing: toggle that region's comment delimiters.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: Is there a way to comment out multiple lines?

Postby aple on Mon Sep 05, 2011 4:44 am

Toggle Comment - Ctrl + /
Toggle Block Comment - Ctrl + Shift + /
aple
 
Posts: 42
Joined: Fri Aug 19, 2011 12:42 pm

Re: Is there a way to comment out multiple lines?

Postby iamntz on Mon Sep 05, 2011 4:45 am

Both of those key bindings are set to the same command: toggle_comment.

Not exactly true.
Ctrl+/ It comments lines like this:
Code: Select all
// line 1
// line 2


On the other hand, ctrl+shift+/ (block comment) will comment lines like this:
Code: Select all
/*
line 1
line 2
*/

(which is... block!)
iamntz
 
Posts: 908
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Is there a way to comment out multiple lines?

Postby atomi on Mon Sep 05, 2011 5:15 am

iamntz wrote:
Both of those key bindings are set to the same command: toggle_comment.

Not exactly true.
Ctrl+/ It comments lines like this:
Code: Select all
// line 1
// line 2


On the other hand, ctrl+shift+/ (block comment) will comment lines like this:
Code: Select all
/*
line 1
line 2
*/

(which is... block!)


Ah okay, it's the argument passed that is different.

Code: Select all
   { "keys": ["ctrl+/"], "command": "toggle_comment", "args": { "block": false } },
   { "keys": ["ctrl+shift+/"], "command": "toggle_comment", "args": { "block": true } },


I guess the follow up question would be, if the block comment is set in the Comments.tmPreferences file where are the comment line preferences set?
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 36 guests