Shortcut to comment out a block of code with sublime text

user749798 picture user749798 · Jul 12, 2012 · Viewed 216.9k times · Source

I want to comment out a block of code in sublime text.

I see it in RailsCasts, but don't think he uses sublime text ... to do the following ...

if (uncommented)
  some uncommented example
  # if (commented) 
  #   some commented example code
  # end
end

Is there a shortcut in sublime text that I can use to insert the block of #'s?

Answer

Randall Ma picture Randall Ma · Jul 12, 2012

The shortcut to comment out or uncomment the selected text or current line:

  • Windows: Ctrl+/
  • Mac: Command ⌘+/
  • Linux: Ctrl+Shift+/

Alternatively, use the menu: Edit > Comment

For the block comment you may want to use:

  • Windows: Ctrl+Shift+/
  • Mac: Command ⌘+Option/Alt+/