-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Repeat last command #27
Comments
That's very interesting. I did some digging, apparently this does not exist in any of the As far as implementation goes, it doesn't seems to be too hard. I am imagining it would be circular buffer storing the history ox commands. However, commands executed in transient and conditional can be a bit tricky. For transient binding (e.g. zooming multiple times
For conditional binding (e.g. like major mode)
The simplest implementation would be just record all the commands history and "replay" it. |
Both your basic and improvement sound reasonable. It's basically like a LRU cache. I like the idea for using |
If these repeat functionality can be exported to a registered command I would prefer assigning it to a vim binding rather than using Example: {
"key": "r",
"command": "whichkey.repeatLastCommand", // Repeats last command
"when": "editorFocus && !extension.simpleVim.insertMode" //I'm using my own fork of Simple Vim.
},
{
"key": "R",
"command": "whichkey.showLastCommands", // Opens Which Keys numbered last command list
"when": "editorFocus && !extension.simpleVim.insertMode"
}, |
Make sense, the function will be exposed as a command so VSpaceCode can bind it in the menu, or people can also bind it anywhere they want :) |
Maybe talking about the API will makes it a little bit clear of what I am thinking. We will have a command to executed the last action by default (with argument it can execute last 2nd, 3rd, etc), a command to open a list of previous actions.
This would be the
I guess if we have |
Yes, perfect! |
I have been thinking a little bit more about transient menu. It seems like it makes more sense to record the action of opening a transient menu instead of the action executed in the transient and the repeat command would only open the transient again. To achieve this, that prompted me to think about refactoring the transient menu into a standalone command (e.g. calling Concretely, instead of {
"key": "J",
"name": "Move lines down",
"type": "transient",
"command": "editor.action.moveLinesDownAction",
"bindings": [
{
"key": "J",
"name": "Move lines down",
"type": "command",
"command": "editor.action.moveLinesDownAction"
},
{
"key": "K",
"name": "Move lines up",
"type": "command",
"command": "editor.action.moveLinesUpAction"
}
]
} we will simply call the command with the argument to locate the config. {
"key": "J",
"name": "Move lines down",
"type": "commands",
"commands": ["editor.action.moveLinesDownAction", "whichkey.showTransient"],
"args": [null, "linesMovingTransient"]
} Refactoring this way also solves #13. Lastly, this also help us implement #12 so it's more like spacemacs. Spacemacs' |
I agree! I think I also got the rest of your comment, and I agree with that, too :) |
Released |
Problem
Sometimes commands requires a lot of key strokes. Repeating last command with single key would be great.
<spc> T T
<spc>
: Opens Which Key => 1 keyShift + t
: Uppercase t, Opens UI Toggles => 2 keyShift + t
: Uppercase t, Toggles Tabs => 2 keyTotal key strokes: 5
Solution
Repeat last command:
<spc> r
Total key strokes: 2
List of last commands:
<spc> R
Repeats last command:
<spc> R 1
Repeats 2nd last command:
<spc> R 2
Repeats 3rd last command:
<spc> R 3
The text was updated successfully, but these errors were encountered: