пятница, 22 января 2010 г.

Vim macroses

In vim u can record a sequence of commands to a register. What does it mean for you? No more tedious text editing, you can record your work and replay it N times.
Assume you need a numbered list:
1
Write the following commands:
qaYp<ctrl a>q

  1. q - start recording
  2. a - write macros into register 'a'
  3. Y - yanks the line
  4. p - paste yanked on the line below
  5. <ctrl a> - increment value
  6. q - stop recording

Now you can write "10@a" to repeat macros from register 'a' 10 times.
The result will be the following:
1
2
3
4
5
6
7
8
9
11
12

Комментариев нет: