Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Using text-registers for macros (POC)

Open elazarcoh opened this issue 3 years ago • 6 comments

This commit is a POC for using plain text registers as Vim macro. Example:

  1. Create a new document, and insert "hello". ihello<Esc>
    hello
    
  2. Create an empty macro at register a. qaq. This is currently required to get register a to be executable.
  3. Insert the requested text macro. oviwc123\<Esc\>A456\<Esc\><Esc>"ayiW. Note: I've escaped \< to note that I want the character '<', and not the '<Esc>' key. (point 4 will make this clearer, I think.)
  4. See that register a contains the required text. :reg a
  5. Delete this line. dd
  6. Execute register a. @a
  7. You should get:
    123456
    

elazarcoh avatar Feb 15 '22 19:02 elazarcoh

The :2d passes, but others are failing now. I'll fix and let you know.

elazarcoh avatar Aug 10 '22 13:08 elazarcoh

Okay. so I fixed some bugs in the tests. Now all of them passing.

elazarcoh avatar Aug 10 '22 14:08 elazarcoh

I'll add some more tests, hopefully soon. Do you think anything else is needed, or it's fine like this?

elazarcoh avatar Aug 10 '22 14:08 elazarcoh

For some reason I cannot make it work with <leader> in reamaps. @J-Fields Do you know why?

elazarcoh avatar Aug 24 '22 10:08 elazarcoh

Nope, I'll try to take a look sometime soon

J-Fields avatar Aug 24 '22 17:08 J-Fields

Fixed it. <leader> as a string is not handled by the handleKeyEvent. It has to be converted to the actual leader key. I added support for it + tests. see expression.ts#L4

elazarcoh avatar Aug 25 '22 08:08 elazarcoh

Hey @elazarcoh what's the status of this - is it ready to merge?

J-Fields avatar Oct 26 '22 04:10 J-Fields

It should be, yes. I couldn't think of any more things that need testing to make sure it doesn't break anything else. If you have an idea for what else should be tested, I can implement it.

elazarcoh avatar Oct 26 '22 04:10 elazarcoh