In Sublime Text 2, how do I enclose a selection in a comment?
Is there a keyboard shortcut for this action?
Learn Sublime Text 3 shortcuts in 12 minutes. Sublime Text 3 shortcuts for Mac and Windows. All the shortcuts discussed in this video can be found here - htt. Create a Sublime Text Keybinding for Reindent For Mac OSX, Linux, and Windows users, the keybindings settings file can be found in the menus Preferences > Keybindings - User. If you haven’t set new keybindings previously the default keymap file JSON looks like this. Keyboard Shortcuts - OSX. Sublime-text-3 sublime-text-2 Downloads pdf htmlzip epub On Read the Docs Project Home Builds Free document hosting provided by Read the Docs.
15 Answers
By default on Linux/Windows for an English keyboard the shortcut is Ctrl+Shift+/ to toggle a block comment, and Ctrl+/ to toggle a line comment.
If you go into Preferences->Key Bindings - Default
, you can find all the shortcuts, below are the lines for commenting.
In the 'Preferences->Key Bindings - User'
Just paste it, these are will work great !
I'd like to add, that on my mac by default block comment toggle shortcut is cmd+alt+/
ArtOfWarfareFor German keyboards use ctrl+shift+# to toggle a block comment and ctrl+# to toggle a line comment.
The shortcut in Preferences->Key Bindings - Default
is set to Ctrl+Shift+/ and Ctrl+/, but to actually use the functions, press the keys stated above.
In a Brazilian Portuguese ABNT2 keyboard I have a similar issue to the one reported by JoshDM. In the file sublime-keymap I have:
But I have to use ctrl+; and ctrl+shift+;. On my keyboard, ; is on the left of /.
It seems like a bug.
ArtOfWarfareyou need to replace '/' with '7', it works on non english keyboard layout.
This did the trick for me coming from Brackets and being used to ctrl+/ on the numpad.
Xavier GuihotIn my keyboard (Swedish) it´s the key to the right of 'ä': '*'.
ctrl+*
ArtOfWarfareIn keyboard (Spanish), SO: Win7.
Go into Preferences->Key Bindings - Default, replace...'ctrl+/']...
by 'ctrl+7'...
And don't use the numpad, it doesn't work. Just use the numbers above the letters
Seems like some kind of keyboard mapping bug. I'm Portuguese, so I'm using a PT/PT keyboard. Sublime Text 3 apparently is handling / as ~.
ArtOfWarfareMax OS: If you want to toggle comment multiple individual lines versus block comment an entire selection, you can do multi line edit, shift+cmd+L, then cmd+/ in that sequence.
First Open The Sublime Text 2.
And top menu bar on select the Preferences
.
And than select the Key Bindings -User
.
And than put this code,
I use Ctrl+Shift+C, You also different short cut key use.
Er CEO Vora MayurEr CEO Vora MayurOn my laptop with spanish keyboard, the problem seems to be the '/' on the key binding, I changed it to ctrl+shift+c and now it works.
eyllanescprotected by eyllanescMar 29 '18 at 19:16
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Not the answer you're looking for? Browse other questions tagged sublimetext2 or ask your own question.
Is there a comprehensive list of keyboard shortcuts for use in Sublime Text 2?
I'm specifically looking for shortcuts that grant me the functionality of the arrow keys, the Home, Delete (NOT Backspace) and End keys without moving my hands off of the home row...
cmccullohcmcculloh5 Answers
I should have dug more before I asked this... They are called 'Key Bindings' and every single one of them is configurable from within a text file. Click 'Preferences' > 'Default Key Bindings' to view them. Copy and paste the ones you want to edit into 'Preferences' > 'User Key Bindings' to and change to your hearts content.
Here is the documentation.
My problem was that I was searching for 'keyboard shortcuts' instead of 'Key Bindings'. Whoops...
To specifically address the question I had, about how to replicate the Delete, Home, End and Arrow keys, I have modified my 'User Key Bindings' file to look like the following:
cmccullohSublime Text 3 Shortcuts Cheat Sheet Mac
cmccullohI created a single page cheat sheet with the default keybindings for Windows:
You can also check out this post on my personal blog which additionally provides a quick explanation of the different possible commands.
Daniel Beck♦You may not have heard of it but there is an app that shows you all the shortcuts of any app on your mac (this includes sublime text 2). You can find it at http://www.grandtotal.biz/CheatSheet/
Standard usage: just hold the command button while the app is running.
Here's the one I am using: http://www.cheatography.com/njovin/cheat-sheets/sublime-text-2-keyboard-shortcuts-windows/
The site lets you narrow down by typing a few words describing the action or the keys.
I use the Package Keymaps which lets you search Key Bindings via the Command Palette.
From the Readme:
Features
Sublime Text 3 Windows 10
- NEW! Search for keymaps by function
- Shows searchable color-coded Cheat Sheet (overview) of keymaps
- Open the keymap file to edit chosen keymap