Home Download Buy Blog Forum Support

Find the command associated with a key

Find the command associated with a key

Postby dang on Thu Dec 13, 2012 7:31 pm

Anyone know if there's a way to look up what command will be executed for a given key combination in a given context? I'm pressing Option-Command-Return and getting strange white dots in the gutter; don't know what they mean or how to find out what this key combo is doing. Thanks for any tips!
dang
 
Posts: 3
Joined: Thu Dec 13, 2012 7:26 pm

Re: Find the command associated with a key

Postby vitaLee on Thu Dec 13, 2012 7:38 pm

type this in sublime's console and all commands will be output there.
sublime.log_commands(True)
vitaLee
 
Posts: 150
Joined: Tue Dec 27, 2011 11:10 pm

Re: Find the command associated with a key

Postby dang on Thu Dec 13, 2012 8:49 pm

That's helpful, but in this specific case it looks like it's running some kind of macro. If I hit Option-Command-Return while working in an HTML file, the output I see in the log is

Code: Select all
no command for selector: breakUndoCoalescing
command: move_to {"to": "hardeol"}
command: move_to {"to": "hardbol"}
command: expand_selection {"to": "word"}
command: move {"by": "characters", "forward": true, "extend":true}
command: move {"by": "wordends", "forward": true, "extend":true}
command: move {"by": "words", "forward": false, "extend":true}
command: move {"by": "characters", "forward": false, "extend":true}
command: set_mark
command: delete_to_mark
command: yank
command: move_to {"to": "hardeol"}
command: left_delete
command: insert {"characters": "\n"}
command: run_macro_file {"file": "Packages/Default/Delete to Hard BOL.sublime-macro"}
command: yank
command: expand_selection {"to": "word"}


Is there any way to tell what the "name" of this series of commands is, what it's supposed to do?
dang
 
Posts: 3
Joined: Thu Dec 13, 2012 7:26 pm

Re: Find the command associated with a key

Postby vitaLee on Thu Dec 13, 2012 10:28 pm

hard to tell.
do a search across keymap files for commands bound to alt+enter or super+enter
Code: Select all
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages && find . -name "*(OSX).sublime-keymap" -print0 | xargs -0 egrep "(super|alt)\+enter"

and check if you have something for those 3 keys. :?
vitaLee
 
Posts: 150
Joined: Tue Dec 27, 2011 11:10 pm

Re: Find the command associated with a key

Postby dang on Thu Dec 13, 2012 10:56 pm

Okay, tried that and got

Code: Select all
./Default/Default (OSX).sublime-keymap:   { "keys": ["super+enter"], "command": "run_macro_file", "args": {"file": "Packages/Default/Add Line.sublime-macro"} },
./Default/Default (OSX).sublime-keymap:   { "keys": ["alt+enter"], "command": "find_all", "args": {"close_panel": true},
./Default/Default (OSX).sublime-keymap:   { "keys": ["alt+enter"], "command": "find_all", "args": {"close_panel": true},
./Default/Default (OSX).sublime-keymap:   { "keys": ["ctrl+alt+enter"], "command": "replace_all", "args": {"close_panel": true},
./Default/Default (OSX).sublime-keymap:   { "keys": ["alt+enter"], "command": "find_all", "args": {"close_panel": true},


I don't see anything here bound to Option-Command-Enter or Alt-Command-Enter or Alt-Super-Enter, so I guess something else must be going on?

More generally, I'm moving to ST2 from TextMate; TM provides a way to either search for a command by name, or to type a key combination and see all commands bound to that. I thought maybe ST2 had a similar feature, but I guess not? Thanks a lot for your help in any case!
dang
 
Posts: 3
Joined: Thu Dec 13, 2012 7:26 pm

Re: Find the command associated with a key

Postby skuroda on Fri Dec 14, 2012 12:29 am

That grep vitaLee specified won't catch everything. Something like `Default.sublime-keymap` will also be used in building the key command list (just independent of the OS).

You may also try using theFindKeyConflicts plugin, which will list commands. It will display "conflicts" or "all keys" (in your case) in either a buffer or the quick panel, giving you some additional searching capability. My guess is what ever command is running is based in a file without an OS specific extension.
Last edited by skuroda on Fri Dec 14, 2012 9:28 am, edited 2 times in total.
skuroda
 
Posts: 689
Joined: Fri Oct 05, 2012 8:11 am

Re: Find the command associated with a key

Postby vitaLee on Fri Dec 14, 2012 8:22 am

ohhh, you are right skuroda.
@dang you can either try the FindKeyConflicts package or try dropping (OSX) from the grep
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages && find . -name "*.sublime-keymap" -print0 | xargs -0 egrep "(super|alt)\+enter"

still not ideal as one would like but that's what we have right now.
vitaLee
 
Posts: 150
Joined: Tue Dec 27, 2011 11:10 pm

Re: Find the command associated with a key

Postby skuroda on Fri Dec 14, 2012 9:31 am

Only know that because I found the FindKeyConflicts plugin wasn't working as expected when I was testing it :) Also realized after posting here that I never got around to adding the Quick Panel option to all keys. So thanks :D
skuroda
 
Posts: 689
Joined: Fri Oct 05, 2012 8:11 am

Re: Find the command associated with a key

Postby vitaLee on Fri Dec 14, 2012 9:37 am

At one point i thought of suggesting the FindKeyConflicts package to dang,
but then i considered that maybe it won't detect the binding he's looking for, because conflicts might not exist.
vitaLee
 
Posts: 150
Joined: Tue Dec 27, 2011 11:10 pm

Re: Find the command associated with a key

Postby skuroda on Fri Dec 14, 2012 10:46 am

Understandable, there has always (okay maybe not always, but for a while) been a command to list all of the keymaps in a single buffer. I just now got around to adding the quick panel display list. FindKeyConflicts is a misleading name, but that's what I was originally shooting for. Not really worth the trouble of changing now though. Well, let's hope that the plugin or grep will help dang solve his problem!
skuroda
 
Posts: 689
Joined: Fri Oct 05, 2012 8:11 am


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 16 guests