Skip to content
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

Repeat last command #501

Closed
mankinskin opened this issue Jul 25, 2021 · 14 comments
Closed

Repeat last command #501

mankinskin opened this issue Jul 25, 2021 · 14 comments
Labels
A-helix-term Area: Helix term improvements C-discussion Category: Discussion or questions that doesn't represent real issues C-enhancement Category: Improvements

Comments

@mankinskin
Copy link

vim has this feature where the last command can be repeated by pressing .. This is very useful and I would love to see this in this editor aswell.

@sudormrfbin
Copy link
Member

Helix does have the dot repeat, but it currently only tracks the last insert mode change (vim tracks every change like ones made with d, c, gU, etc). Tracking every change would be better.

@archseer
Copy link
Member

archseer commented Jul 25, 2021

Yeah this is equivalent to kakoune's ., there's also alt-. to repeat last selection (which we still need). It doesn't track other commands either from what I can tell, since it can't tell what the intended selection is (imagine xd for example, we repeat the d on what?).

@cessen
Copy link
Contributor

cessen commented Jul 30, 2021

imagine xd for example, we repeat the d on what?

How much utility is there in the . command if it's only typically meaningful for insertions? I wonder if focusing on a more general macro recording system would make more sense.

(I realize vim also has a macro system, and that doesn't obviate the utility of .. I'm just wondering if, in our case, given the reduced utility of . compared to vim if it would be better to drop it entirely and just try to make macros really fast and ergonomic.)

@heliostatic
Copy link
Contributor

Just adding a vote for normal mode . for my very lazy use case: 10j and then . -- I use this daily in vim, would love a simple equivalent in Helix.

@mankinskin
Copy link
Author

@heliostatic For this I think you would be much better served with Ctrl-d and Ctrl-u, right? I'm on my phone so I'm not sure if helix has this, but I believe it has.
In vim I also added remaps for Ctrl-j to 4j and for k respectively for small jumps.. not sure if remaps are possible in helix as of now.

@kirawi kirawi added A-helix-term Area: Helix term improvements C-discussion Category: Discussion or questions that doesn't represent real issues C-enhancement Category: Improvements labels Aug 19, 2021
@pickfire
Copy link
Contributor

Just adding a vote for normal mode . for my very lazy use case: 10j and then . -- I use this daily in vim, would love a simple equivalent in Helix.

Movement stuff should be covered under alt-. like kakoune. . should only cover manipulation. Macro wise, both should be covered.

@archseer
Copy link
Member

archseer commented Jan 6, 2022

We have both ., Alt-. and macros now.

@archseer archseer closed this as completed Jan 6, 2022
@sudormrfbin
Copy link
Member

Maybe we should have . repeat both action and change by default and keep around the individual commands to be remappable if desired. A keybind to do both . and Alt-. can't be defined in the config file right now since . is a special cased key. Moreover, I think repeating both selection and change is the more common case and it would be useful to have it by default on ..

Even if it's not made the default, refactoring the current . behavior (of repeating only last change) into a proper command would enable having a command sequence of "repeat selection, repeat change" be mappable in the config file.

@pinpox
Copy link
Contributor

pinpox commented Jun 9, 2023

Maybe we should have . repeat both action and change by default

+1 for this. In it's current state . is not nearly as powerful as in vim. While macros can cover some of the use-cases, I use the dot command quite often in vim to repeat a change or deletion I just did on some textobject and fould another occurence where it is needed aftewards. Macros, search/replace and multiple cursors all require me to know in advance all occurances where I will need that edit, which is quite different than the very useful
"Oh, here's another one! Let's do the same change" presses . as muscle memory

Making . repeat changes and deletions on textobjects would be a big improvement in my opinion.

@tarunsharma20
Copy link

+1 for this. One of the main reasons I can't use any other text editor besides vim is the repeat command. It appears that we are utilising three commands in Helix to do the same task. macro, Alt-., and .

Having the ability to repeat the last command would be fantastic if we could alter text case, add/update/delete text, edit surround, etc.

@goosethedev
Copy link

Yeah this is equivalent to kakoune's ., there's also alt-. to repeat last selection (which we still need). It doesn't track other commands either from what I can tell, since it can't tell what the intended selection is (imagine xd for example, we repeat the d on what?).

On the line where the cursor currently is, as if you pressed xd again.

From Practical Vim (2nd ed):

The dot command lets us repeat the last change. It is the most powerful and versatile command in Vim.

I hope this feature gets the priority it deserves.

@archseer
Copy link
Member

And to re-iterate: Helix is based on kakoune bindings, so Practical Vim has no relevance here.

.: repeat last insert mode change (i, a, or c, including the inserted text)

Think about it. The selection first model requires you to build a bunch off selections first, then operate on them. It's much harder to determine exactly what you want to repeat since selecting is also part of movement. Do we repeat just the last selecting operation, then the action? That likely won't be what you want. Do we repeat all selecting operations since the last change? Well that won't be what you want either since it'll involve scrolling and other movement.

@goosethedev
Copy link

The selection first model requires you to build a bunch off selections first, then operate on them.

Yes, I agree this breaks the selection-first model. But under this perspective, so do macros, a feature present in Kakoune and experimental here. The dot command could be seen as an automatically recorded macro for the last action, as if we pressed again the same keys with one single keystroke.

I think at least it would be worth it as an additional command repeat_last_action and leave to the user the decision to bind it or not.

Also thanks for the quick reply! I'm sorry if I'm missing something, I didn't use Kakoune at all.

@robinmoussu
Copy link

robinmoussu commented Sep 21, 2024

And to re-iterate: Helix is based on kakoune bindings, so Practical Vim has no relevance here.

I would have totally expected . in helix to repeat the last selection then the last command, where the notion of last selection is reset every time the selection is reset.

For example:

  • weeed would record w for the last selection and d for the action, since both w and e reset the selection every time they are pressed
  • weveed would record evee for the last selection
  • wCCCed would record CCCe for the selection
  • wCCC(ed would record CCC(e for the selection

That being said, I was very surprised to see that alt-. only repeats f, t and m motions and not compound motion (like evee, CCCe and CCC(e in my example above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-discussion Category: Discussion or questions that doesn't represent real issues C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests