photo of warehouse

Vim macros and register that I always forget

0

So I keep forgetting how useful macros (and registers are) or repetitive things. Basically, Vi has 10 numeric registers and then alphabetic registers.

If you want to see them then type :registers and you can see what is stored there. There are two ways to use them. The first is to stick thinks into a registry, you name register this way with a double quote (get it you are quoting a string and sticking it in). So the way this works is that you name the tag and then yank to copy it and put to paste it in:

  • “ayW – This means <register> is a and then yank a whole word
  • “aP – This means take the contents of register A and put it before the cursor

Then there is a completely different use of the same register which is to record a macro. This is actually just a text string that gets played back, so you do this by q <register> then a string of command and then an ending q. Then play back is @<register>:

  • qadWq. This says start a quote a string put it into register A, then record delete an entire word. Then the second q means the end of the macro
  • @a. This means run macro in register a

Related Posts

This site uses Akismet to reduce spam. Learn how your comment data is processed.