Sublime Forum

Is there a command palette history?

#1

Hi people,

I wonder if there exist a command palette history and a command to re-run the last command executed from the command palette. I know there is the command history available in the API, but that’s for all commands. I mean, something similar, except just for the command palette alone.

I like the command palette a lot, just that I feel it’s tedious to re‑type words all the time while in a time range I’m often reusing the two or three same commands. A quick‑panel with just the three or four (no more) last commands selected in the command palette, that’s something like that I’m thinking about (and additionally, a straight way to re‑run the last one).

0 Likes

#2

In a session (e.g. .sublime-workspace or the auto-session in the Data directory), you may find that pretty much all previously entered queries into the command palette are saved. It’s like an ordered dictionary, a list of two-tuples that saves your selection for each query you did.

I do not know how often sessions get updated however.

Furthermore, on ST3 at least the palette always opens with the last run command already selected, including the last query.

0 Likes

#3

Indeed. Just that a shortcut for this, miss me (something like Ctrl+Letter).

I will have a look at the workspace data.

0 Likes

#4

Sorry for reviving the 10-years old thread, but recently I wondered the same. The sublime-workspace file contains a “command_palette” node with a “selected_items” nodes under it, which actually contains the history of commands selected in the Command Palette.
My question is: how can I access the items from this history of commands? I tried different combinations such as Alt+/Ctrl+/Shift+Left, Alt+/Ctrl+/Shift+Up, but none has worked.
Mu guess is the following: as the command history is saved, there should be a way of accessing this history from the Command Palette, right?
Here is the reason: I found myself to repeatedly type the same commands in the Command Palette again and again, so it would be really useful to access the previously used commands by means of some shortcut.

0 Likes

#5

The history of the command palette associates the text that was used in the input and the command that was selected by the user when the input was typed:

[
    "synjson",
    "Set Syntax: JSON"
],
[
    "edit",
    "Project: Edit Project"
],

That is, I typed synjson and selected the command to set the syntax to JSON, and after typing edit, amongst the filtered responses I chose the one to edit the project.

Sublime uses these such that the next time I type edit in the command palette, although many commands will filter in, the selected one will be the one to edit the project.

Apart from this, there’s no history of commands in the sense you mean here. The usual use case is something along the lines of binding a key to things you use frequently and using the command palette to find things you don’t use frequently (which will then also show you the key binding associated, if there is one, for next time).

0 Likes

#6

Even though the original intention was different - as you described - these items still already contain the commands history! I mean, the keys “synjson” and “edit” from your example are in fact the command history items I was talking about!
To me, taking your example, it would make perfect sense to press something like Alt+Up or Alt+BackSpace in the Command Pallette and get “synjson” as the result (the filter in the Command Pallette), with the “Set Syntax: JSON” item selected. Then, pressing Alt+Up or Alt+BackSpace again, one would get “edit” as the result, with “Project: Edit Project” item selected. In case of exactly two mappings (as in this example), the next Alt+Up or Alt+BackSpace would clear (empty) the filter in the Command Pallette.

0 Likes