annotate runtime/macros/life/life.vim @ 31227:1a9e44a45614 v9.0.0947

patch 9.0.0947: invalid memory access in substitute with function Commit: https://github.com/vim/vim/commit/cc762a48d42b579fb7bdec2c614636b830342dd5 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Nov 25 13:03:31 2022 +0000 patch 9.0.0947: invalid memory access in substitute with function Problem: Invalid memory access in substitute with function that goes to another file. Solution: Check for text locked in CTRL-W gf.
author Bram Moolenaar <Bram@vim.org>
date Fri, 25 Nov 2022 14:15:05 +0100
parents bd021eb62e73
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Macros to play Conway's Game of Life in vi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Version 1.0m: edges wrap
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 7
diff changeset
3 " by Eli-the-Bearded Benjamin Elijah Griffin <vim@eli.users.panix.com>
46bbe11644e0 updated for version 7.2a
vimboss
parents: 7
diff changeset
4 " Sept 1996
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " This file may be free distributed so long as these credits remain unchanged.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " Modified by Bram Moolenaar (Bram@vim.org), 1996 Sept 10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " - Made it quite a bit faster, but now needs search patterns in the text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " - Changed the order of mappings to top-down.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " - Made "g" run the whole thing, "C" run one generation.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 " - Added support for any uppercase character instead of 'X'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " Rules:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 " If a germ has 0 or 1 live neighbors it dies of loneliness
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 " If a germ has 2 or 3 live neighbors it survives
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 " If a germ has 4 to 8 live neighbors it dies of starvation
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 " If an empty box has 3 live neighbors a new germ is born
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 " A new born germ is an "A". Every generation it gets older: B, C, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 " A germ dies of old age when it reaches "Z".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 " Notice the rules do not mention edges. This version has the edges wrap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 " around. I have an earlier version that offers the option of live edges or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " dead edges. Email me if you are interested. -Eli-
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 " Note: This is slow! One generation may take up to ten minutes (depends on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 " your computer and the vi version).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " Quite a lot of the messy stuff is to work around the vi error "Can't yank
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 " inside global/macro". Still doesn't work for all versions of vi.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 " To use these macros:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 " vi start vi/vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 " :so life.mac Source this file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 " g 'g'o! runs everything until interrupted: "IR".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 " I Initialize everything. A board will be drawn at the end
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 " of the current buffer. All line references in these macros
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 " are relative to the end of the file and playing the game
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 " can be done safely with any file as the current buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 " Change the left field with spaces and uppercase letters to suit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 " your taste.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 " C 'C'ompute one generation.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 " + idem, time running one generation.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 " R 'R'un 'C'ompute until interrupted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 " i<nr><Esc>z Make a number the only thing on the current line and use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 " 'z' to time that many generations.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 " Time to run 30 generations on my 233 AMD K6 (FreeBSD 3.0):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 " vim 5.4 xterm 51 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " gvim 5.4 Athena 42 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 " gvim 5.4 Motif 42 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 " gvim 5.4 GTK 50 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 " nvi 1.79 xterm 58 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 " vi 3.7 xterm 2 min 30 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 " Elvis 2.1 xterm 7 min 50 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 " Elvis 2.1 X11 6 min 31 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 " Time to run 30 generations on my 850 AMD Duron (FreeBSD 4.2):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 " vim 5.8 xterm 21 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 " vim 6.0 xterm 24 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 " vim 6.0 Motif 32 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 " nvi 1.79 xterm 29 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 " vi 3.7 xterm 32 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 " elvis 2.1.4 xterm 34 sec
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 " And now the macros, more or less in top-down order.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 " ----- macros that can be used by the human -----
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " 'g'o: 'I'nitialize and then 'R'un 'C'ompute recursively (used by the human)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 map g IR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 " 'R'un 'C'ompute recursively (used by the human and 'g'o)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 map R CV
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 " work around "tail recursion" problem in vi, "V" == "R".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 map V R
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 " 'I'nitialize the board (used by the human and 'g'o)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 map I G)0)0)0)0)1)0)0)2)0)0)0)0,ok,-11k,-,R,IIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 " 'C'ompute next generation (used by the human and others)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 map C T>>>>>>>>B&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 " Time running one generation (used by the human)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 map + <1C<2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 " Time running N generations, where N is the number on the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 " (used by the human)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 map z ,^,&,*,&<1,*<2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 " ----- END of macros that can be used by the human -----
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 " ----- Initialisation -----
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 map ,- :s/./-/g
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 map ,o oPut 'X's in the left box, then hit 'C' or 'R'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 map ,R 03stop
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 " Write a new line (used by 'I'nitialize board)
20115
bd021eb62e73 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
111 " In remembrance of John Conway, 26 December 1937 – 11 April 2020.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 map )0 o- --....................--....................-
20115
bd021eb62e73 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
113 map )1 o- JOHN CONWAY --....................--....................-
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 map )2 o- LIVES --....................--....................-
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 " Initialisation of the pattern/command to execute for working out a square.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 " Pattern is: "#<germ><count>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 " where <germ> is " " if the current germ is dead, "X" when living.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 " <count> is the number of living neighbours (including current germ)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 " expressed in X's
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 map ,Il8 O#XXXXXXXXXX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 map ,Id8 o# XXXXXXXX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 map ,Il7 o#XXXXXXXXX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 map ,Id7 o# XXXXXXX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 map ,Il6 o#XXXXXXXX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 map ,Id6 o# XXXXXX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 map ,Il5 o#XXXXXXX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 map ,Id5 o# XXXXX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 map ,Il4 o#XXXXXX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 map ,Id4 o# XXXX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 map ,Il3 o#XXXXX .,a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 map ,Id3 o# XXX .`a22lrA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 map ,Il2 o#XXXX .,a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 map ,Id2 o# XX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 map ,Il1 o#XXX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 map ,Id1 o# X .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 map ,Il0 o#XX .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 map ,Id0 o# .`a22lr 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 "
14999
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 1618
diff changeset
142 " Patterns used to replace a germ with its next generation
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 map ,Iaa o=AB =BC =CD =DE =EF =FG =GH =HI =IJ =JK =KL =LM =MN =NO =OP =PQ =QR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 map ,Iab o=RS =ST =TU =UV =VW =WX =XY =YZ =Z 
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 " Insert the searched patterns above the board
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 map ,IIN G?^top ,Il8,Id8,Il7,Id7,Il6,Id6,Il5,Id5,Il4,Id4,Il3,Id3,Il2,Id2,Il1,Id1,Il0,Id0,Iaa,Iab
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 " ----- END of Initialisation -----
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 " ----- Work out one line -----
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 " Work out 'T'op line (used by show next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 map T G,c2k,!9k,@,#j>2k,$j
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 " Work out 'B'ottom line (used by show next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 map B ,%k>,$
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 " Work out a line (used by show next, work out top and bottom lines)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 map > 0 LWWWWWWWWWWWWWWWWWW,rj
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 " Refresh board (used by show next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 map & :%s/^\(-[ A-Z]*-\)\(-[ A-Z]*-\)\(-[.]*-\)$/\2\3\3/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 " Work around vi multiple yank/put in a single macro limitation
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 " (used by work out top and/or bottom line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 map ,$ dd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 map ,% "cp
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 map ,! "byy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 map ,@ "cyy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 map ,# "bP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 map ,c c$
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 " ----- END of Work out one line -----
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 " ----- Work out one square -----
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 " The next three work out a square: put all nine chars around the current
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 " character on the bottom line (the bottom line must be empty when starting).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 " 'W'ork out a center square (used by work out line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 map W makh,3`ah,3`ajh,3(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 " Work out a 'L'eft square (used by work out line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 map L makf-h,1`ak,2`af-h,1`a,2`ajf-h,1`aj,2(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 " Work out a 'R'ight square (used by work out line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 map ,r makh,2`akF-l,1`ah,2`aF-l,1`ajh,2`ajF-l,1(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 " 'M'ove a character to the end of the file (used by all work out square
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 " macros)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 map ,1 y G$p
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 map ,2 2y G$p
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 map ,3 3y G$p
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 " ----- END of Work out one square -----
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 " ----- Work out one germ -----
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 " Generate an edit command that depends on the number of living in the last
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 " line, and then run the edit command. (used by work out square).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 " Leaves the cursor on the next character to be processed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 map ( ,s,i,X0i?^#A  0,df.l,Y21h
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 " Delete 's'paces (deads);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 " The number of remaining characters is the number of living neighbours.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 map ,s :.g/ /s///g
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 " Insert current character in the last line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 map ,i `ay GP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 " Replace any uppercase letter with 'X';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 map ,X :.g/[A-Z]/s//X/g
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 " Delete and execute the rest of the line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 map ,d "qd$@q
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 " Yank and execute the rest of the line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 map ,Y "qy$@q
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 " Yank the character under the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 map ,j y
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 " Put the current cut buffer after the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 map ,m p
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 " Delete the character under the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 map ,n x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 "
14999
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 1618
diff changeset
236 " Replace a character by its next, A --> B, B --> C, etc.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 map ,a `a,jGi?=,ma 0,dll,j`a21l,ml,nh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 " ----- END of Work out one germ -----
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 " ----- timing macros -----
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 " Get current date (used by time a generation)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 map << :r!date
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 map <1 G?^top O<<
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 map <2 G?^top k<<
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 " Turn number on current line into edit command (used by time N generations)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 map ,^ AiC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 " Delete current line and save current line (used by time N generations)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 map ,& 0"gd$
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 " Run saved line (used by time N generations)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 map ,* @g
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 " ----- END of timing macros -----
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 " End of the macros.