How do I toggle comments with German keyboard?

3

2

Sublime text uses Ctrl+/ to toggle comments. However, when I press that combination with a German keyboard layout (where / is Shift+7), nothing happens. Selecting Toggle Comment in Ctrl+Shift+P works fine, and shows Ctrl+/ as the shortcut.

The shortcut does work fine when switching to English keyboard layout and I press the keys labelled Ctrl+-.

phihag

Posted 2016-05-19T09:36:44.337

Reputation: 2 557

Can't you just use the / from the numeric block, i'm doing the same with other IDEs? – martinstoeckli – 2016-05-19T11:00:27.560

@martinstoeckli I'm using a laptop keyboard, so no numeric block (not even with Fn). – phihag – 2016-05-19T11:04:32.523

3The shortcut maps in the german keyboard to ctrl+#. – r-stein – 2016-05-20T06:46:57.113

@r-stein Thanks for the note, but it doesn't work for me by default, and I see no line in the default config that would have that effect. Did you maybe reconfigure something? – phihag – 2016-05-20T07:39:01.110

@phihag if you open the ST console View >>> Show Console and write sublime.log_input(True) it logs the input events. The input event when pressingctrl+# should be control+/. – r-stein – 2016-05-20T08:17:07.767

@rstein No, it shows up as control+#. May be platform-specific? This is on debian sid. – phihag – 2016-05-20T08:24:04.603

1@phihag Okay it seems to be platform specific. – r-stein – 2016-05-20T08:35:53.440

Answers

3

The default Sublime Text 3 binding seems to detect Ctrl+Shift+7 with a German keyboard layout as just that, so you need to add an additional shortcut. Click Preferences -> Key Bindings - User and insert the following line in the JSON array:

{"keys": ["ctrl+shift+7"], "command": "toggle_comment", "args": {"block": true}}

phihag

Posted 2016-05-19T09:36:44.337

Reputation: 2 557