-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Macro #894
Merged
Merged
Macro #894
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6f98e0f
initial version
rebornix 1d02e5b
abstract type
rebornix 81cd355
replay keystrokes
rebornix bd41d20
add test cases for Macro from Practical Vim
rebornix 643262c
Append command to existing macro
rebornix c91df69
test all test cases
rebornix 65027d2
fix append command to macro
rebornix 014fc12
support repeating Macro
rebornix 7fa5597
support to run last invoked macro
rebornix 3746ee1
Code formart
rebornix e203e04
abort when a motion fails
rebornix 62c6a04
travis is not smart about upper/lower case
rebornix 2024e50
stop macro once motions fail
rebornix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just immediately produce the stringified macro right here instead of shipping it off to some text transformation thing? The transformations are supposed to only be when you're actually changing the content in the text editor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planing to do so but later on I found we are doing this way for
dot
command, which is similar to Macros. Besides, actually I do want to delegate back the real content change/ action execution back to modeHandler, any ideas to do so if we don't leveragetransformations
? I usetransformations
as a way of lazy execution.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're actually performing a macro at this point, then we absolutely should use a transformation.
But it looked to me like we were just storing the content of the macro in a register, which doesn't require any text transformations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmn, I agree. In this particular case, we just need to insert all the keystrokes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnfn just played with Vim again and found that running
Ctrl-R {register}
is actually performing the macro stored in{register}
.For example, you recored
ab<BS>c<Esc>
in registera
, which representsEnter Insert Mode, insert b, backspace, insert c
. Repeating this macro in Normal mode will just insertc
and return back to Normal Mode. If you are in Insert Mode and run<C-r> a
, what gets inserted isac
. The firsta
is translated toInsert a as it's Insert Mode
and then perform all following keystrokes.