hotkeyszerobraneuser-preferences

Change menu item hotkeys using the user.lua file


I'm trying to change the comment/uncomment hotkey, but it's not working. I'm on a Mac, but I want to actually use the Ctrl key modifier instead of the Cmd key. Since the hotkey that I want to use is already assigned to something else, I'm trying to assign that hotkey too, to avoid conflict.

I've typed the following in the user settings and saved the file, but it's not working. The default hotkeys are still in effect.

--[[--
  Use this file to specify **User** preferences.
  Review [examples](+/Volumes/ZeroBraneStudio/ZeroBraneStudio.app/Contents/ZeroBraneStudio/cfg/user-sample.lua) or check [online documentation](http://studio.zerobrane.com/documentation.html) for details.
--]]--

  keymap[ID.REPPLACEINFILES] = "Ctrl-Alt-R"
  keymap[ID.REPLACE]         = "Ctrl-Shift-R"
  keymap[ID.COMMENT]         = "Ctrl-R"

What am I doing wrong or missing?


Solution

  • Since the hotkey that I want to use is already assigned to something else, I'm trying to assign that hotkey too, to avoid conflict.

    This is the correct idea.

    I see two reasons: you have a typo in ID.REPPLACEINFILES (double P) and Ctrl is always mapped to Cmd on macOS. You need to use RawCtrl instead (as it's mapped to Ctrl on all platforms, including macOS). See this section for details: https://github.com/pkulchenko/ZeroBraneStudio/blob/master/src/editor/keymap.lua#L27-L29