Sublime Forum

What is the quickest way to run a command?

#1

Hi, so far I noticed I can run a command by add an entry into User key mapping, but is there another quicker way without even map a key to the command? I tried Command Palette, but it doesn’t show all the commands, nor it will run any explicit command give.

0 Likes

#2

The console will run anything (view>console).

0 Likes

#3

Ah, I tried view.run_command('example') and it works. Thanks adzenith!

PS: However I still wish ST2 should have something even more easier. Like a prompt to enter just the command name etc. Since command is such frequent used thing, it would be really useful to have.

0 Likes

#4

You can add whatever you want to the Command Palette, create a Default.sublime-commands in your user folder based on the content of:

\Sublime Text 2\Packages\Default\Default.sublime-commands

You can also use a small plugin to ask the command and run it:

import sublime, sublime_plugin class AskCommandCommand(sublime_plugin.WindowCommand): def run(self): def _on_done_cmd(cmd): self.window.run_command(cmd) self.window.show_input_panel('Command:', '', _on_done_cmd, None, None)
Note that this example only work for parameters less command, but adding a second prompt for parameters is easy.

0 Likes