Next: , Previous: History, Up: Improvements over Vi

2.4 Macros and Registers

Viper facilitates the use of Emacs-style keyboard macros. @# will start a macro definition. As you type, the commands will be executed, and remembered (This is called “learn mode” in some editors.) @register will complete the macro, putting it into ‘register’, where ‘register’ is any character from ‘a’ through ‘z’. Then you can execute this macro using @register. It is, of course, possible to yank some text into a register and execute it using @register. Typing @@, @RET, or @C-j will execute the last macro that was executed using @register.

Viper will automatically lowercase the register, so that pressing the SHIFT key for @ will not create problems. This is for @ macros and "p only. In the case of y, "Ayy will append to register a. For [,],',`, it is an error to use a Uppercase register name.

The contents of a register can be seen by ]register. ([textmarker will show the contents of a textmarker).

The last keyboard macro can also be executed using *, and it can be yanked into a register using @!register. This is useful for Emacs style keyboard macros defined using C-x( and C-x). Emacs keyboard macros have more capabilities. See Keyboard Macros, for details.

Keyboard Macros allow an interesting form of Query-Replace: /pattern or n to go to the next pattern (the query), followed by a Keyboard Macro execution @@ (the replace).

Viper also provides Vi-style macros. See Vi Macros, for details.