1 DGD editor reference guide
4 The DGD editor is line oriented. It has two different modes, Command Mode
5 and Insert Mode. In Command Mode, commands may be given that affect a range of
6 lines in the main buffer. In Insert Mode, new lines may be added to the main
7 buffer. Apart from the main buffer, lines may be copied to and from 26
8 secondary buffers.
9 The editor remembers the current line and at most 26 marked lines in the
10 main buffer, and has some status-affecting variables which can be changed by the
14 1. Insert Mode
16 In Insert Mode, each line typed by the user is inserted into the main buffer.
17 Insert Mode is indicated by the prompt '*'. Insert Mode is entered with the
18 commands 'append', 'change' and 'insert' from Command Mode, and is left by
19 typing a line consisting of a single '.'.
22 2. Command Mode
24 In Command Mode, the user may issue commands that affect the current line,
25 all lines or a specified range of lines. Command Mode is indicated by the
26 prompt ':'. After a command has been executed, the new current line will
27 usually be displayed. The most general format of commands is as follows:
29 address1 , address2 command ! parameters count flags
31 <address1> and <address2> specify the first and last line of a range of lines
32 that are to be affected by the command. If no second line address is given,
33 the range is assumed to be <address1, address1>. If no line range is specified
34 at all, a default range is assumed, usually just the current line.
35 <command> is a string of letters or non-digits.
36 <!> may be given with some commands to specify a different, but similar
38 Some commands require <parameters>.
39 A <count> may be given with many commands to specify the number of lines
40 that is to be affected by the command, as an alternative to specifying the
41 first and last line. A <count> will always override <address2>, if given.
42 Finally, <flags> may be given to affect the way in which the new current
43 line is displayed after the command has been executed.
45 All parts are optional, even the command itself may be omitted. A range of
46 lines without a following command will print the lines specified. A single
47 <address> will set the current line to <address>, and the 'empty command' will
48 set the current line to the next line.
51 2.1 Line addressing
53 An <address> specifies a line in the main buffer. It may be a number, '.'
54 or '$', a regular expression, a marked line, or an expression containing one of
55 the previous and an offset. The most general format is:
57 [number | . | $ | /pattern/ | ?pattern? | 'm] [+ | -] [number]
59 Lines in the main buffer are numbered starting with 1. A number may be
60 given to specify a line. '.' denotes the current line, and '$' the last line
61 in the main buffer.
62 A regular expression must be enclosed within '/' or '?' pairs. '/pattern/'
63 will search forward, starting with the line after the current line, and
64 '?pattern?' will search backward. If no pattern is specified, '//' or '??' will
65 respectively search forward and backward, using the previous regular expression.
66 If the regular expression forms the whole command, the closing '/' or '?' may be
68 A marked line is specified by a single quote "'", followed by a lowercase
69 letter. The mark must have been set by the 'mark' command.
71 Offsets may be given to a given <address> using '+' and '-', followed by
72 a number. If the '+' or '-' sign is not preceded by an <address>, the current
73 line is assumed. If the '+' or '-' sign is not followed by a number, the number
74 1 is assumed. Offsets may be repeated, with a cumulative effect.
76 A range of lines is indicated by <address1, address2>. Either of the
77 addresses may be omitted:
79 <address, > means <address, address>
80 <, address> means <., address>
81 <,> means <., .>
83 Alternatively, ',' can be replaced with ';'. This has the effect of setting
84 the current line to <address1>, just before <address2> is evaluated.
85 '%' is an alias for '1,$'.
88 2.1.1 Regular expressions
90 In a regular expression, characters may form a string that is searched for in
91 the main buffer. Only strings on a single line can be searched for. Some
92 characters and character sequences have a special meaning in regular
95 ^ matches the beginning of the line.
96 $ matches the end of the line.
97 . matches any single character.
98 \< matches the beginning of a word (LPC identifier).
99 \> matches the end of a word (LPC identifier).
100 [string] matches any single character in the string between the square
101 brackets. a-z specifies a range of characters, and if the
102 first character following the opening '[' is '^', any character
103 NOT in the string is matched.
104 * matches 0, 1 or more occurances of the preceding (single
105 character matching) pattern.
106 \( and \) does not match a pattern, but indicate the beginning and end of
107 a subpattern that can be used in the 'substitute' command.
109 If any of the symbols '^', '$', '.', '[', '*' or '\' itself is desired in
110 regular expressions, it should be prefixed by '\'.
111 Depending on the value of the 'ignorecase' variable, which can be changed
112 with the 'set' command, lowercase letters may match either just the lowercase
113 letter or both uppercase and lowercase. By default, only lowercase letters are
117 2.1.2 Marked lines
119 Lines in the main buffer can be given a mark, consisting of a lowercase
120 letter, which afterwards can be used in line addresses to refer to the marked
121 line. This is done with the 'mark' command.
124 2.2 Secondary buffers
126 Apart from the main buffer, the editor maintains 26 secondary buffers which
127 are addressed by letters. A range of lines from the main buffer may be copied
128 into a secondary buffer, and the contents of a secondary buffer may be copied
129 into the main buffer. When copying lines to a secondary buffer, a lowercase
130 letter indicates that the previous contents of the secondary buffer (if any) is
131 to be replaced, and an uppercase letter indicates that the lines are to be
132 appended to the secondary buffer. When copying back lines from a secondary
133 buffer, case of the letter specifying the buffer is not significant.
136 2.2.1 Default buffer
138 Each command that has the option of copying lines into a secondary buffer,
139 always stores the lines in a default buffer also. If no secondary buffer is
140 specified when lines are copied back to the main buffer, lines are copied from
141 the default buffer.
144 2.3 Flags
146 Many commands may followed by one of the characters 'p', 'l', '#', '+' and
147 '-', which affect the way in which the current line is displayed after the
148 command is executed or, if the command itself prints lines, in which way these
149 lines are printed. The characters have the following meaning:
151 p print the current line after the command has finished. This usually
152 happens automatically.
153 l print the current line after the command has finished, in 'list' format.
154 # print the current line after the command has finished, in 'number'
156 + increase the current line number by 1 before printing it.
157 - decrease the current line number by 1 before printing it.
159 Flags may be repeated, with a cumulative effect.
162 2.4 Multiple commands inside a global command
164 More than one command may be given inside a global command, by separating
165 the individual commands with '|'.
168 2.5 Command summary
170 In the following list of commands, the default line range is shown in
171 parenthesis, and an optional parameter is marked with '[' ']'. After each
172 command, the current line is set at the last line changed or displayed.
175 RANGE COMMAND ABBREV
177 (.) append a
178 Enter Insert Mode and append lines after the specified line.
179 A line address of 0 may be given to indicate that lines are to
180 be inserted before the first line in the main buffer.
182 (.,.) change [count] c
183 Enter Insert Mode and replace the specified lines.
185 (.,.) copy address [count] [flags] co
186 Place a copy of the specified lines after the given address.
187 The address may be 0, in which case the copied lines are
188 inserted before the first line in the main buffer.
190 (.,.) delete [buffer] [count] [flags] d
191 Delete the specified lines. The deleted lines are saved in the
192 default buffer, and in the secondary buffer if one is specified.
194 edit [file] e
195 Start editing a new file. The current main buffer and all
196 secondary buffers will be discarded. The current line will be
197 placed at the last line of the main buffer.
199 edit! [file] e!
200 Start editing a new file, even if the current main buffer was
203 file [file] f
204 Show statistics on the current file edited. If an argument is
205 given, the current file name is changed into the one specified.
207 (1,$) global /pattern/ [command] g
208 Execute the command on all lines matching the given pattern.
209 By default, the matching lines are just printed.
211 (1,$) global! /pattern/ [command] g!
212 Execute the command on all lines not matching the given pattern.
213 By default, the lines that don't match are just printed.
215 (.) insert i
216 Enter Insert Mode and insert lines before the specified one.
218 (.,.+1) join [count] [flags] j
219 Join the specified lines together in a single line. White
220 space at the beginning of a next line will be discarded.
221 Unless the next line starts with ')', a space is inserted
222 between two joined lines, or two spaces if the first line ends
223 in '.'.
225 (.,.+1) join! [count] [flags] j!
226 Join the specified lined together in a single line without
227 white space processing.
229 (.,.) list [count] [flags] l
230 Show the specified lines, displaying tabs as '^I' and marking
231 the end of the line with '$'.
233 (.) mark x k
234 Mark the specified line with x, a single lowercase letter. If
235 the abbreviation 'k' is used, there need not be any spaces
236 between the command and the argument.
238 (.,.) move address [flags] m
239 Reposition the specified lines after the given address.
241 (.,.) number [count] [flags] #
242 Display the specified lines, preceded by their line number.
244 (.,.) print [count] [flags] p
245 Display the specified lines.
247 (.) put [buffer] pu
248 Copy lines from the secondary buffer, or from the default
249 buffer if none is given, after the specified line.
251 quit q
252 Quit this editing session.
254 quit! q!
255 Quit this editing session, even if the main buffer has been
258 (.) read [file] r
259 Place a copy of the text in [file] after the specified line.
261 set [parameter] se
262 Set without argument shows the current values of the editor
263 variables. Variables are numeric or toggles. Toggles can be
264 turned on with 'set option' and turned off with 'set nooption'.
265 Numeric variables can be given a value with 'set numeric=value'.
266 The following variables exist:
268 NAME ABBREV DEFAULT MEANING
270 ignorecase ic noic ignore case in searches.
271 shiftwidth sw 4 affects the '<', '>' and 'I'
273 window wi 20 specifies the number of lines
274 displayed with the z command.
277 (.,.) substitute /pattern/replacement/ [g] [count] [flags] s
278 Replace <pattern> by <replacement> in the specified lines. If
279 the 'g' option is specified, repeat the substitution in each
280 line until all occurrances of <pattern> have been replaced.
281 In <replacement>, \x, where x is a digit in range 1-9, specifies
282 the xth subexpression in <pattern>, which is enclosed by \( \)
283 pairs in <pattern>. Furthermore, '&' in <replacement> specifies
284 the text that matched <pattern>, and '\n' in <replacement>
285 specifies a newline, splitting the line in two. If the symbols
286 '&' and '\' themselves are desired in <replacement>, they should
287 be prefixed by '\'. All parameters are optional. 'substitute'
288 by itself will repeat the previous substitution.
290 (.,.) t address [flags]
291 An alias for the 'copy' command.
293 undo u
294 Undo the effects of the previous command on the main buffer.
295 'edit' and 'yank' commands can not be undone, and 'global'
296 commands are undone as a whole.
298 (1,$) v /pattern/ [command]
299 An alias for the 'global!' command.
301 (1,$) write [file] w
302 Write the specified lines to [file], or to the current file if
303 no argument is specified.
305 (1,$) write! [file] w!
306 Write the specified lines to [file], even if some error
307 occurred that prevented the main buffer from containing an exact
308 image of the file that is being edited.
310 (1,$) write >> [file] w>>
311 This variant of write appends to a file, instead of overwriting
314 (1,$) wq [file]
315 Write the main buffer to the current file, and quit this
316 editing session.
318 (1,$) wq! [file]
319 Write the main buffer to the current file and quit this editing
320 session, even if some error occurred that prevented the main
321 buffer from containing an exact image of the file that is being
324 xit [file] x
325 Write the main buffer to the current file if it was modified,
326 and quit this editing session.
328 (.,.) yank [buffer] [count] [flags] y
329 Copy the specified lines to the secondary buffer given in the
330 argument, or just to the default buffer if no argument is given.
332 (.+1) z [mode] [flags]
333 Show a page of lines, starting with the specified line. The
334 number of lines displayed is determined by the value of the
335 'window' variable, which can be changed by the 'set' command.
336 [mode] can be one of the following:
338 + show specified line at top of page (default)
339 . show specified line in middle of page
340 - show specified line at bottom of page
343 (.,.) < [count] [flags]
344 Leftshift the specified lines the number of spaces given by the
345 'shiftwidth' variable, which can be changed by the 'set' command.
347 (.,.) > [count] [flags]
348 Rightshift the specified lines the number of spaces given by the
349 'shiftwidth' variable, which can be changed by the 'set' command.
351 ($) =
352 Show the specified line number.
354 (1,$) I [flags]
355 Indent the specified lines, under the assumption that they are
356 LPC code. The number of spaces used for indentation is given by
357 the 'shiftwidth' variable, which can be changed by the 'set'
This page was automatically generated by the
Visit the LXR main site for more