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
Save the .
#6299
Comments
I really like this idea, and think that this would be a great addition. Here's some brainstorming on how this could be offered:
|
Item from the todo list which may be relevant:
|
I've wished for this for a long time, going back to my vi days. Like there's a scratch register for deleted or changed text, could there be a scratch register that records every change? So macro recording is always on? |
On 2020-06-19, lacygoill wrote:
Item from the todo list which may be relevant:
Redo only remembers the last change. Could use "{count}g." to redo an older
change. How does the user know which change? At least have a way to list
them: ":repeats". Add to history, like search history and command line
history.
I like that. I had thought of keeping each change in a stack, so
that you could pop the last change off the stack if you wanted the
one before, but I like this better. It would be especially nice if
"g." (without a count) executed the next-to-last change.
Regards,
Gary
|
On 2020-06-19, lacygoill wrote:
> Item from the todo list which may be relevant:
>
> Redo only remembers the last change. Could use "{count}g." to redo an older
> change. How does the user know which change? At least have a way to list
> them: ":repeats". Add to history, like search history and command line
> history.
I like that. I had thought of keeping each change in a stack, so
that you could pop the last change off the stack if you wanted the
one before, but I like this better. It would be especially nice if
"g." (without a count) executed the next-to-last change.
There are some questions about how this behaves exactly. E.g. after
using "3g." does that redo operation become the current one, so that "."
will redo it again? That's a bit like how the command history works.
Then will "3g." do the same thing, or have the entries shifted?
:repeats could list them with the "g.", "2g.", etc. command that would
execute them.
I would find this most useful when going through a list of matches,
either with "n" or ":cn", and seeing something else that needs changing.
If that is only one operation that using "g." would work, but if that
ends up being two or three changes, you get lost. Perhaps we need a way
to "save the current redo" and "restore the saved redo"? Or switching
between two redo histories.
…--
If cars evolved at the same rate as computers have, they'd cost five euro,
run for a year on a couple of liters of petrol, and explode once a day.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
When I first thought how handy something like this would be, the way I imagined it working would be to automatically store the relevant keys for the previous change in a read-only register. |
I think there even was a patch for accessing the |
Yes, I would expect it to become the current one, so I can continue using it with Just having |
Thank you @chrisbra . I really like this idea and would love to see it in mainline Vim. |
@brammool maybe [also] working with 'g,', 'g;' would be better, enhance it: echo the last 'repeat' at that location, then 'g.' switch to it, now '.' can repeat that one .. |
I use |
jump-in .. :) |
I think it would be really really nice if vim implemented functionality of |
This exposes the last redo command (what "." runs) in the "," register; "." already contains the last inserted text and "," is the next best thing. The previous redo command is available in the ";" register. Both can be read and written to, so to restore the previous one you could do something like: nnoremap <silent> g. :let [@,, @;] = [@;, '']<CR> This is something I frequently want, for example I search for "some_text", do "cwothertext" ("change word"), "n." a few times, but in one instance I find some other (often small) change I need to do, or want to change "some_text" to something else just this one time. But doing that will have me lose the "." contents. Issue vim#6299 contains some discussion about a "redo history" and "3g." command, a :repeats command, etc. The idea is to provide some basic "primitives" so people can do Clever Things™ with it, such as the mapping above. This is a much smaller change, probably enough for most use cases, and will still be useful if that's implemented later on (although this could possibly just be a bundled VimScript plugin, which will be easier to maintain than writing it all in C). For more extensive history, a RedoChanged autocmd can be added: var redo_hist = [] autocmd RedoChanged * add(redo_hist, @,) # Matches against @,? I'll work on that after this is merged.
This exposes the last redo command (what "." runs) in the "," register; "." already contains the last inserted text and "," is the next best thing. The previous redo command is available in the ";" register. Both can be read and written to, so to restore the previous one you could do something like: nnoremap <silent> g. :let [@,, @;] = [@;, '']<CR> This is something I frequently want, for example I search for "some_text", do "cwothertext" ("change word"), "n." a few times, but in one instance I find some other (often small) change I need to do, or want to change "some_text" to something else just this one time. But doing that will have me lose the "." contents. Issue vim#6299 contains some discussion about a "redo history" and "3g." command, a :repeats command, etc. The idea is to provide some basic "primitives" so people can do Clever Things™ with it, such as the mapping above. This is a much smaller change, probably enough for most use cases, and will still be useful if that's implemented later on (although this could possibly just be a bundled VimScript plugin, which will be easier to maintain than writing it all in C). For more extensive history, a RedoChanged autocmd can be added: var redo_hist = [] autocmd RedoChanged * add(redo_hist, @,) # Matches against @,? I'll work on that after this is merged.
This exposes the last redo command (what "." runs) in the "," register; "." already contains the last inserted text and "," is the next best thing. The previous redo command is available in the ";" register. Both can be read and written to, so to restore the previous one you could do something like: nnoremap <silent> g. :let [@,, @;] = [@;, '']<CR> This is something I frequently want, for example I search for "some_text", do "cwothertext" ("change word"), "n." a few times, but in one instance I find some other (often small) change I need to do, or want to change "some_text" to something else just this one time. But doing that will have me lose the "." contents. Issue vim#6299 contains some discussion about a "redo history" and "3g." command, a :repeats command, etc. The idea is to provide some basic "primitives" so people can do Clever Things™ with it, such as the mapping above. This is a much smaller change, probably enough for most use cases, and will still be useful if that's implemented later on (although this could possibly just be a bundled VimScript plugin, which will be easier to maintain than writing it all in C). For more extensive history, a RedoChanged autocmd can be added: var redo_hist = [] autocmd RedoChanged * add(redo_hist, @,) # Matches against @,? I'll work on that after this is merged.
This exposes the last redo command (what "." runs) in the "," register; "." already contains the last inserted text and "," is the next best thing. The previous redo command is available in the ";" register. Both can be read and written to, so to restore the previous one you could do something like: nnoremap <silent> g. :let [@,, @;] = [@;, '']<CR> This is something I frequently want, for example I search for "some_text", do "cwothertext" ("change word"), "n." a few times, but in one instance I find some other (often small) change I need to do, or want to change "some_text" to something else just this one time. But doing that will have me lose the "." contents. Issue vim#6299 contains some discussion about a "redo history" and "3g." command, a :repeats command, etc. The idea is to provide some basic "primitives" so people can do Clever Things™ with it, such as the mapping above. This is a much smaller change, probably enough for most use cases, and will still be useful if that's implemented later on (although this could possibly just be a bundled VimScript plugin, which will be easier to maintain than writing it all in C). For more extensive history, a RedoChanged autocmd can be added: var redo_hist = [] autocmd RedoChanged * add(redo_hist, @,) # Matches against @,? I'll work on that after this is merged.
I often search through text or code and use the
.
command to repeat my change (for example change a name etc.).Halfway through I notice another change I'd like to make (e.g. remove a misplaced comma, add an s to the end of a word ...) but by making the change my
.
command would be cleared.So now I either have to interrupt my workflow, make the change and then start again or remember the position to go back later.
I think being able to save the action of the
.
to a register and later repeat it as a macro would solve the problem.The text was updated successfully, but these errors were encountered: