1 .TH mcedit 1 "30 January 1997"
4 mcedit \- Full featured terminal text editor for Unix-like systems.
8 [[+number] file [\-bcCdfhstVx?]]
13 the Midnight Commander, forcing it
14 to immediately start its internal editor. The editor is a terminal
17 standalone X Window editor.
22 Go to the line specified by number (do not insert
23 a space between the "+" sign and the number).
26 Forces black and white display.
29 Force color mode on terminals where
31 defaults to black and white.
33 .I "\-C <keyword>=<FGcolor>,<BGcolor>:<keyword>= ..."
34 Used to specify a different color set, where
36 is one of normal, selected, marked, markselect, errors,
37 reverse menu, menusel, menuhot, menuhotsel and gauge. The colors
38 are optional and are one of black, gray, red, brightred, green,
39 brightgreen, brown, yellow, blue, brightblue, magenta,
40 brightmagenta, cyan, brightcyan, lightgray and white.
48 Disables mouse support.
51 Displays the compiled-in search paths for Midnight Commander files.
54 Used only if the code was compiled with Slang and terminfo: it makes
55 the Midnight Commander use the value of the
57 variable for the terminal information instead of the information on
58 the system wide terminal database
61 Displays the version of the program.
64 Forces xterm mode. Used when running on xterm-capable terminals (two
65 screen modes, and able to send mouse escape sequences).
68 The internal file editor provides most of the features of
69 common full screen editors. It has an extensible file size
70 limit of sixteen megabytes and edits binary files
71 flawlessly. The features it presently supports are: Block
72 copy, move, delete, cut, paste;
73 .I "key for key undo";
75 menus; file insertion; macro definition; regular expression
76 search and replace (and our own scanf-printf search and
77 replace); shift-arrow MSW-MAC text highlighting (for the
78 linux console only); insert-overwrite toggle; word-wrap;
79 a variety of tabbing options; syntax highlighting for
80 various file types; and an option
81 to pipe text blocks through shell commands like indent and
85 The editor is very easy to use and requires no tutoring.
86 To see what keys do what, just consult the appropriate
87 pull-down menu. Other keys are: Shift movement
88 keys do text highlighting (Linux console only).
91 .BR "~/.cedit/cooledit.clip",
95 .BR "~/.cedit/cooledit.clip".
98 .BR "~/.cedit/cooledit.clip",
101 deletes highlighted text - all linux console only.
102 The completion key (see
104 also does a hard return
105 without an automatic indent. Mouse highlighting also works, and you
106 can override the mouse as usual by holding down the shift key
107 while dragging the mouse to let normal terminal mouse highlighting
110 To define a macro, press
112 and then type out the key
113 strokes you want to be executed. Press
115 again when finished. You can then assign the macro to any key you
116 like by pressing that key. The macro is executed when you press
118 and then the assigned key. The macro is also executed if
119 you press Meta, Ctrl, or Esc and the assigned key, provided that the
120 key is not used for any other function. Once defined, the macro
121 commands go into the file
122 .BR "~/.cedit/cooledit.macros".
123 Do NOT edit this file unless you are not going to use macros again
124 in the same editing session, because
126 caches macro key defines in memory.
128 now overwrites a macro if a macro with the same key already exists,
129 so you won't have to edit this file. You will also have to restart
130 other running editors for macros to take effect.
133 will format C code when it is highlighted. For this
134 to work, make an executable file called
135 .B .cedit/edit.indent.rc
136 in your home directory containing the following:
141 # Use $HOME instead of ~ if this doesn't work.
142 # You may also have to use a different redirection
143 # syntax for some machines.
144 /usr/bin/indent -kr -pcs ~/.cedit/cooledit.block >& /dev/null
145 cat /dev/null > ~/.cedit/cooledit.error
149 will run ispell on a block of text in a similar way. The file
151 .B .cedit/edit.spell.rc
155 # Use $HOME instead of ~ if this doesn't work.
156 # You may also have to use a different redirection
157 # syntax for some machines.
158 /usr/local/bin/ispell ~/.cedit/cooledit.block >& /dev/null
159 cat /dev/null > ~/.cedit/cooledit.error
163 Keys may be redefined from the Midnight Commander options
166 .SH SYNTAX HIGHLIGHTING
167 As of version 3.6.0, \fBcooledit\fP has syntax highlighting. This means
168 that keywords and contexts (like C comments, string constants, etc) are
169 highlighted in different colours. The following section explains the
170 format of the file \fB~/.cedit/syntax\fP.
172 The file \fB~/.cedit/syntax\fP is rescanned on opening of a any new
173 editor file. The file contains rules for highlighting, each of which is
174 given on a separate line, and define which keywords will be highlighted
175 to what colour. The file is also divided into sections, each beginning
176 with a line with the \fBfile\fP command, followed by a regular
177 expression. The regular expression dictates the file name that that set
178 of rules applies to. Following this is a description to be printed on the
179 left of the editor window explaining the file type to the user. A third
180 optional argument is a regular expression to match the first line of
181 text of the file. If either the file name matches, or the first line of text,
182 then those rules will be loaded.
184 A section ends with the start of a new section. Each section is divided
185 into contexts, and each context contains rules. A context is a scope
186 within the text that a particular set of rules belongs to. For instance,
187 the region within a C style comment (i.e. between \fB/*\fP and \fB*/\fP)
188 has its own colour. This is a context, although it will have no further
189 rules inside it because there is probably nothing that we want
190 highlighted within a C comment.
192 A trivial C programming section might look like this:
195 file .\\*\\\\.c C\\sProgram\\sFile (#include|/\\\\\\*)
197 wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
202 keyword whole else 24
204 keyword whole while 24
206 keyword whole switch 24
207 keyword whole case 24
208 keyword whole static 24
209 keyword whole extern 24
217 # C preprocessor directives
218 context linestart # \\n 18
229 Each context starts with a line of the form:
231 \fBcontext\fP [\fBexclusive\fP] [\fBwhole\fP|\fBwholeright\fP|\fBwholeleft\fP]
232 [\fBlinestart\fP] \fIdelim\fP [\fBlinestart\fP] \fIdelim\fP [\fIforeground\fP] [\fIbackground\fP]
235 One exception is the first context. It must start with the command
237 \fBcontext\fP \fBdefault\fP [\fIforeground\fP] [\fIbackground\fP]
239 or else \fBcooledit\fP will return an error.
241 The \fBlinestart\fP option dictates that \fIdelim\fP must start at
242 the beginning of a line.
244 The \fBwhole\fP option tells that delim must be a whole word. What
245 constitutes a whole word are a set of characters that can be
246 changed at any point in the file with the \fBwholechars\fP
247 command. The \fBwholechars\fP command at the top just sets the
248 set exactly to its default and could therefore have been omitted. To
249 specify that a word must be whole on the left only, you can use
250 the \fBwholeleft\fP option, and similarly on the right. The left and
251 right set of characters can be set separately with,
253 \fBwholechars\fP [\fBleft\fP|\fBright\fP] \fIcharacters\fP
255 The \fBexclusive\fP option causes the text between the delimiters to be
256 highlighted, but not the delimiters themselves.
258 Each rule is a line of the form:
260 \fBkeyword\fP [\fBwhole\fP|\fBwholeright\fP|\fBwholeleft\fP] [\fBlinestart\fP]
261 \fIstring\fP \fIforeground\fP [\fIbackground\fP]
264 Context or keyword strings are interpreted so that you can include tabs
265 and spaces with the sequences \\t and \\s. Newlines and the \\ are
266 specified with \\n and \\\\ respectively. Since whitespace is used as a
267 separator, it may not be used explicitedly. Also, \\* must be used to
268 specify a *. The * itself is a wildcard that matches any length of
269 characters. For example,
273 colours all C single character constants green. You could also have
278 to colour string constants, except that the matched string may not cross
279 newlines. \fIThe wildcard may be used within context delimiters as
280 well\fP, but you \fBcannot have a wildcard as the last or first character\fP.
282 Important to note is the line
286 This line defines a keyword containing the \\ and newline characters.
287 Because keywords have a higher precedence than context delimiters, this
288 keyword prevents the context from ending at the end of a line if the
289 line ends in a \\ thus allowing C preprocessor directive to continue
290 across multiple lines.
292 The colours themselves are numbered 0 to 26 and are explained below in
293 \fBFURTHER BEHAVIORAL OPTIONS\fP. You can also use \fBany\fP of the named
294 colors specified in \fB/usr/lib/X11/rgb.txt\fP, though only one word
295 versions of them. It is better to stick to the numerical colors
296 to limit use of the color palette.
298 Comments may be included on a line of there own and begin with
301 Because of the simplicity of the implementation, there are a few
302 intricacies that will not be coped with correctly but these are a minor
303 irritation. On the whole, a broad spectrum of quite complicated
304 situations are handled with these simple rules. It is a good idea to
305 take a look at the syntax file to see some of the nifty tricks you can
306 do with a little imagination. If you can't get by with the rules I have
307 coded, and you think you have a rule that would be useful, please email
308 me with your request. However, do not ask for regular expression
309 support, because this is flatly impossible.
311 A useful hint is to work with as much as possible with the things
312 you \fIcan\fP do rather than try to do things that this
313 implementation can't cope with. Also remember that the aim of
314 syntax highlighting is to make programming less prone to error,
315 \fInot\fP to make code look pretty.
318 The default colors may be changed by appending to the
319 \fBMC_COLOR_TABLE\fP environment variable. Foreground and
320 background colors pairs may be specified for example with:
323 MC_COLOR_TABLE="$MC_COLOR_TABLE:\
324 editnormal=lightgray,black:\
325 editbold=yellow,black:\
326 editmarked=black,cyan"
330 Most options can now be set from the editors options dialog
331 box. See the \fBOptions\fP menu. The following options are defined in
332 \fB.mc.ini\fP, and have obvious correspondences in the dialog box.
333 You can modify them to change the editor behavior, by editing the file.
334 Unless specified, a 1 sets the option to on, and a 0 sets it to
338 This option is ignored when invoking
341 .I editor_key_emulation
344 keys, and 0 for normal
348 .I editor_tab_spacing
349 Interpret the tab character as being of this length.
350 Default is 8. You should avoid using
351 other than 8 since most other editors and text viewers
352 assume a tab spacing of 8. Use
353 .B editor_fake_half_tabs
354 to simulate a smaller tab spacing.
356 .I editor_fill_tabs_with_spaces
357 Never insert a tab space. Rather insert spaces (ascii 20h) to fill to the
360 .I editor_return_does_auto_indent
361 Pressing return will tab across to match the indentation
362 of the first line above that has text on it.
364 .I editor_backspace_through_tabs
365 Make a single backspace delete all the space to the left
366 margin if there is no text between the cursor and the left
369 .I editor_fake_half_tabs
370 This will emulate a half tab for those who want to program
371 with a tab spacing of 4, but do not want the tab size changed
372 from 8 (so that the code will be formatted the same when displayed
373 by other programs). When editing between text and the left
374 margin, moving and tabbing will be as though a tab space were
375 4, while actually using spaces and normal tabs for an optimal fill.
376 When editing anywhere else, a normal tab is inserted.
378 .I editor_option_save_mode
379 (0, 1 or 2.) The save mode (see the options menu also)
380 allows you to change the method
381 of saving a file. Quick save (0) saves the file by immediately,
382 truncating the disk file to zero length (i.e. erasing it)
383 and the writing the editor contents to the file. This method
384 is fast, but dangerous, since a system error during a file
385 save will leave the file only partially written, possibly
386 rendering the data irretrievable. When saving, the safe save (1)
387 option enables creation of a temporary file into which the
388 file contents are first written. In the event of an problem,
389 the original file is untouched. When the temporary file is
390 successfully written, it is renamed to the name of the original
391 file, thus replacing it. The safest method is create
392 backups (2). Where a backup file is created before any changes
393 are made. You can specify your own backup file extension in
394 the dialog. Note that saving twice will replace your backup
395 as well as your original file.
399 (Scanf search and replace have previously not worked properly.
400 With this release, problems with search and replace have been
403 You can use scanf search and replace to search and replace
404 a C format string. First take a look at the
408 man pages to see what a format string
409 is and how it works. An example is as follows: Suppose you want
410 to replace all occurrences of say, an open bracket, three
411 comma separated numbers, and a close bracket, with the
414 the third number, the word
416 and then the second number, you would fill in the Replace dialog
420 .B Enter search string
422 .B Enter replace string
424 .B Enter replacement argument order
428 The last line specifies that the third and then the second
429 number are to be used in place of the first and second.
431 It is advisable to use this feature with Prompt On Replace on, because
432 a match is thought to be found whenever the number of arguments found
433 matches the number given, which is not always a real match. Scanf also
434 treats whitespace as being elastic. Note that the scanf format %[ is
435 very useful for scanning strings, and whitespace.
437 The editor also displays non-us characters (160+). When editing
438 binary files, you should set
440 to 7 bits in the Midnight Commander options menu to keep the
447 The help file for the program.
449 @prefix@/lib/mc/mc.ini
451 The default system-wide setup for the Midnight Commander, used only if
452 the user lacks his own ~/.mc.ini file.
454 @prefix@/lib/mc/mc.lib
456 Global settings for the Midnight Commander. Settings in this file are
457 global to any Midnight Commander, it is useful to define site-global
460 .\"Terminal databases"
464 User's own setup. If this file is present then the setup is loaded
465 from here instead of the system-wide startup file.
469 User's own temporary directory where block commands are processed
474 This program is distributed under the terms of the GNU General Public
475 License as published by the Free Software Foundation. See the built-in
476 help of the Midnight Commander for details on the License and the lack
479 The latest version of this program can be found at
480 ftp://ftp.gnome.org/mirror/gnome.org/stable/sources/mc/ and on the
481 mirrors listed on the GNOME site http://www.gnome.org/.
483 cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
486 Paul Sheer (psheer@obsidian.co.za) is the developer of
487 the Midnight Commander's internal editor.
492 in the distribution for more information.