Language VIM Macro
(VIM can execute @register macros)
Date: | 05/25/10 |
Author: | Herman Suijs |
URL: | n/a |
Comments: | 3 |
Info: | http://www.vim.org |
Score: | (2.95 in 19 votes) |
i99 bottles of beer on the wall, ^[0"o4yw4w"p3yw$"opoTake one down and pass it around, ^["op"ppa.^M^[8b^Xo 3YP3j^Q^X8w^Q^Xj^Q^Xk^[0"bd$kk99@b3k:.,$s/0/no more/g :g/[^-]1 bottles/s/es/e/g^M/^no/^M~j:s/-1/99/^M3cwGo to the store^[2w3cwbuy some more^[
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
Herman Suijs said on 06/27/10 23:22:03
A ^M is missing at the end of the second line.
Be sure to have all characters on 1 line in VIM. It is also important to replace the following characters:
^M for CTRL-Q CTRL-M
^Q for CTRL-Q CTRL-Q
^X for CTRL-Q CTRL-X
^[ for CTRL-Q Esc
Go to the start of the line and issue the following commands:
"ad$
@a
The first line means: delete the whole line and put it in buffer a.
The second line means: execute buffer a as a macro.
barrym said on 07/14/10 07:16:53
Did I mess up your recommended modifications to the source?
My version is missing a period after 'beer', and it thinks that
11 is a singular as well as 1.
Herman Suijs said on 08/23/10 13:41:25
You are precise and correct:
- for the period: First line change "opoTake into "opi.^MTake
- for the 11 (and 11+10*[1-8]): Last line change :g/[^-]1 into :g/[^1-9]1
Which makes:
i99 bottles of beer on the wall, ^[0"o4yw4w"p3yw$"opi.^MTake one down and pass it around, ^["op"ppa.^M^[8b^Xo 3YP3j^X8w^Xj^Xk^[0"bd$kk99@b3k:.,$s/0/no more/g^M:g/[^-1-9]1 bottles/s/es/e/g^M/^no/^M~j:s/-1/99/^M3cwGo to the store^[2w3cwbuy some more^[^M
Apologies for the large portion of code