ctrl+space key binding not working for commenting in Sublime Text 3

≡放荡痞女 提交于 2019-12-13 14:00:58

问题


After installing Sublime Text 3 (Build 3059) I tried to configure some key bindings as I usually did in the past. So I configured this in "Preferences \ Key Bindings - User":

[
  { "keys": ["ctrl+space"], "command": "toggle_comment", "args": { "block": false } }
]

Well, this simply does not work. I can see the key binding is registered when I hover over to "Edit \ Comment \ Toggle Comment" as there is the key binding shown in grey right next to the "Toggle Comment" text. Commenting works when I click the Toggle Comment menu item, but not with the key binding.

When binding shift+space commenting works as expected. So, why won't ctrl+space do?


回答1:


It's work only when file Syntax is defined.

Press Ctrl+Shift+P and type name of syntax, like Java, C++, PHP, Ruby, SQL etc...

Default (Linux) settings:

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

Line comment:

Ctrl+/

Block comment:

Ctrl+Shift+/




回答2:


Maybe not a Sublime Text 3 problem.

Something is grabbing the keyboard shortcut before it reaches the editor.

As you are on ubuntu 14.04 my best guess is ibus.

See the issue on their launchpad: ibus breaks emacs and eclipse control-space keybinding

Maybe the given workaround run "ibus exit" in .config/lxsession/Lubuntu/ suites you.

cheers,

Martin




回答3:


So, it had to do with ibus. I could fix it by following these steps:

  1. $ sudo apt-get install dconf-editor
  2. $ dconf-editor
  3. Go to desktop \ ibus \ general \ hotkey
  4. Change the value for triggers from ['<Control>space'] to []


来源:https://stackoverflow.com/questions/24905104/ctrlspace-key-binding-not-working-for-commenting-in-sublime-text-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!