I went to the official Workbench keyboard shortcut page and found this:
Function | Keyboard Shortcut | Context
-------------------------------+-------------------+-----------
Comment/Uncomment lines of SQL | Modifier+/ | SQL Editor
However, Control+/ doesn't work.
I have MySQL Workbench installed on a Windows machine. How do you get the shortcut to work?
Thanks for filing the bug report, it's annoying.
If you have a full size keyboard try using the division symbol.
i.e. The CONTROL + "/" using the division key above the keypad instead of the "?/" key on the main keyboard.
It's not nearly as convenient, but it works for me with Windows 7 and MYSQL Workbench 6.1.
Works for me when I press either of the Ctrl buttons + / ("slash button" in Num Pad)
Instead you can also simple type "#" at the Point of line you want to comment.
- example:
#SELECT * FROM images where category_name = "cars";
comments the whole line
I can confirm that this works on OS X and Linux, but it's failing on Windows. This is likely a bug, please file a bug report at bugs.mysql.com.
It is now May 2019 and this is still an open issue. There is a work around there but it doesn't work either. Here is what I have done for my v8.0.15
.
Close MySQL Workbench if you have it open. Find the menu XML
file at [path-to-mysql-workbench-folder]\data\main_menu.xml
. Open in any editor and search for toggle comment
. You should find this menu item:
<value type="object" struct-name="app.MenuItem" id="com.mysql.wb.menu.edit.
<link type="object" key="owner" struct-name="app.MenuItem">
com.mysql.wb.menu.edit.format_menu</link>
<value type="string" key="accessibilityName">Toggle Comment on Selection</value>
<value type="string" key="caption">Un/Comment Selection</value>
<value type="string" key="name">comment</value>
<value type="string" key="command">plugin:wb.sqlide.comment</value>
<value type="string" key="itemType">action</value>
<value type="string" key="shortcut">Modifier+Slash</value>
</value>
Change the key="shortcut"
portion from Modifier+Slash
to anything that isn't taken, and that does not contain 'Slash' in it. I have it set to Modifier+Alt+D
. Feel free to set it to what helps you, and try out different combinations if you are having issues. Start up MySQL Workbench and try out your fully working shortcut!
Don't forget you can also manually do this by going to the menu Edit -> Format -> Un/Comment Selection
. You can also use the division symbol (forward slash) near the full size keypad if you have one. This should work without any changes, but not nearly as convenient.
I just encountered this issue, and came upon this thread. I found a work around and way to restore the functionality.
It seems when there are more than ond set of dashes ("--") it appends more "--" turns into "-- --"
So i just did a find replace "--" for "". That reset all my comments and the functionality now works as expected. (Press "Ctrl+ /" it makes dashes for the highlighted rows, press again and removes them).
Restarting had no effect for me.
On my keyboard, in Windows 10, I found to make this work I needed to:
- select the text to be commented
- press Fn key
- press CTRL+/
- when done, press Fn key