Reputation: 15
The popup window with a function's docstring is very useful in the Sublime Anaconda package, however it shows only if I type the function or right click -> Anaconda -> Show Documentation.
When reading someone else's code, I would like to look up what a functions docstring without having to right click or use workaround like deleting and retyping the last character of a function.
Is there a shortcut I am missing? I would anticipate there exist one to view the popup window.
Upvotes: 0
Views: 1945
Reputation: 22791
Generally speaking, if you can trigger an action by choosing an item from a menu, you can also bind a key to it (and vice-versa).
To do so, you would open the Sublime console with Ctrl+` or View > Show Console
and enter the command sublime.log_commands(True)
to turn on command logging. Once that's done, execute the command (in this case by choosing the item from the context menu) and see what's logged in the console.
For this command, the output is something like this:
command: anaconda_doc {"event": {"x": 344.5, "y": 644.5}}
This indicates that the command being executed is anaconda_doc
; the arguments are the location the mouse was at when you issued the command.
With this in hand, you can use Preferences > Key Bindings
and bind a key to the command anaconda_doc
to trigger the same command via a key shortcut.
That said, the documentation for the package is linked from it's Package Control page, and that documentation has a section for how to view doc strings that outlines the ways to trigger this, which includes a default key binding:
When a package has it's own default key bindings, they're generally visible in it's section of the Preferences menu, which in this case would be Preferences > Package Settings > Anaconda > Key Bindings - Default
; choosing that will show you how the binding is defined so you can change it (by copying it to your user setting and altering the keys):
{
"command": "anaconda_doc", "keys": ["ctrl+alt+d"], "context": [
{"key": "selector", "operator": "equal", "operand": "source.python"}
]
},
The default binding ensures that it only triggers in Python source files.
Upvotes: 2