Home Download Buy Blog Forum Support

What is the quickest way to run a command?

What is the quickest way to run a command?

Postby saltnlight5 on Thu Sep 27, 2012 12:51 am

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.
saltnlight5
 
Posts: 12
Joined: Fri Sep 07, 2012 2:20 pm

Re: What is the quickest way to run a command?

Postby adzenith on Fri Sep 28, 2012 12:06 am

The console will run anything (view>console).
adzenith
 
Posts: 1213
Joined: Mon Oct 19, 2009 9:12 pm

Re: What is the quickest way to run a command?

Postby saltnlight5 on Mon Oct 01, 2012 3:32 am

Ah, I tried
Code: Select all
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.
Zemian Deng
---------------
http://saltnlight5.blogspot.com
saltnlight5
 
Posts: 12
Joined: Fri Sep 07, 2012 2:20 pm

Re: What is the quickest way to run a command?

Postby bizoo on Mon Oct 01, 2012 6:05 am

You can add whatever you want to the Command Palette, create a Default.sublime-commands in your user folder based on the content of:
Code: Select all
\Sublime Text 2\Packages\Default\Default.sublime-commands


You can also use a small plugin to ask the command and run it:
Code: Select all
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.
bizoo
 
Posts: 873
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 15 guests