* screen.c: Make functions static whenever possible. Remove
[midnight-commander.git] / doc / mcedit.1.in
blob7d40d9de89ecc75175f1d45241291adb571e86fd
1 .TH mcedit 1 "30 January 1997"
2 .\"SKIP_SECTION"
3 .SH NAME
4 mcedit \- Full featured terminal text editor for Unix-like systems.
5 .\"SKIP_SECTION"
6 .SH USAGE
7 .B mcedit
8 [[+number] file [\-bcCdfhstVx?]]
9 .SH DESCRIPTION
10 .LP
11 Mcedit is a link to 
12 .B mc,
13 the Midnight Commander, forcing it 
14 to immediately start its internal editor. The editor is a terminal 
15 version of the 
16 .B cooledit 
17 standalone X Window editor.
18 .\".\"DONT_SPLIT"
19 .SH OPTIONS
20 .TP
21 .I "+number"
22 Go  to the line specified by number (do not insert
23 a space between the "+" sign and the number).
24 .TP
25 .I "\-b"
26 Forces black and white display.
27 .TP
28 .I "\-c"
29 Force color mode on terminals where 
30 .B mcedit 
31 defaults to black and white.
32 .TP
33 .I "\-C <keyword>=<FGcolor>,<BGcolor>:<keyword>= ..."
34 Used to specify a different color set, where 
35 .I keyword 
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.
41 See the 
42 .B Colors 
43 section in 
44 .B mc.1 
45 for more information.
46 .TP
47 .I "\-d"
48 Disables mouse support.
49 .TP
50 .I "\-f"
51 Displays the compiled-in search paths for Midnight Commander files.
52 .TP
53 .I "\-t"
54 Used only if the code was compiled with Slang and terminfo: it makes
55 the Midnight Commander use the value of the 
56 .B TERMCAP
57 variable for the terminal information instead of the information on
58 the system wide terminal database
59 .TP
60 .I "\-V"
61 Displays the version of the program.
62 .TP
63 .I "\-x"
64 Forces xterm mode.  Used when running on xterm-capable terminals (two
65 screen modes, and able to send mouse escape sequences).
66 .PP
67 .SH Features
68 The internal file editor provides most of the features of common full
69 screen editors.  It has an extendable file size limit of sixteen megabytes
70 and edits binary files flawlessly.  The features it presently supports
71 are: Block copy, move, delete, cut, paste;
72 .I "key for key undo"; 
73 pull-down
74 menus; file insertion; macro definition; regular expression
75 search and replace (and our own scanf-printf search and
76 replace); shift-arrow MSW-MAC text highlighting (for the
77 linux console only); insert-overwrite toggle; word-wrap;
78 a variety of tabbing options; syntax highlighting for
79 various file types; and an option
80 to pipe text blocks through shell commands like indent and
81 ispell.
82 .PP
83 .SH Keys
84 The editor is very easy to use and requires no tutoring.
85 To see what keys do what, just consult the appropriate
86 pull-down menu. Other keys are: Shift movement
87 keys do text highlighting (Linux console only). 
88 .B Ctrl-Ins 
89 copies to the file 
90 .BR ~/.mc/cedit/cooledit.clip,
91 and 
92 .B Shift-Ins 
93 pastes from 
94 .BR ~/.mc/cedit/cooledit.clip. 
95 .B Shift-Del 
96 cuts to 
97 .BR ~/.mc/cedit/cooledit.clip, 
98 and 
99 .B Ctrl-Del 
100 deletes highlighted text - all linux console only. 
101 The completion key (see 
102 .BR "mc.1") 
103 also does a hard return
104 without an automatic indent. Mouse highlighting also works, and you
105 can override the mouse as usual by holding down the shift key
106 while dragging the mouse to let normal terminal mouse highlighting
107 work.
109 To define a macro, press 
110 .B Ctrl-R 
111 and then type out the key
112 strokes you want to be executed. Press 
113 .B Ctrl-R 
114 again when finished. You can then assign the macro to any key you
115 like by pressing that key. The macro is executed when you press
116 .B Ctrl-A 
117 and then the assigned key. The macro is also executed if
118 you press Meta, Ctrl, or Esc and the assigned key, provided that the
119 key is not used for any other function. Once defined, the macro
120 commands go into the file 
121 .BR ~/.mc/cedit/cooledit.macros. 
122 Do NOT edit this file if you are going to use macros again in the same
123 editing session, because
124 .B Mcedit 
125 caches macro key defines in memory. 
126 .B Mcedit 
127 now overwrites a macro if a macro with the same key already exists,
128 so you won't have to edit this file. You will also have to restart
129 other running editors for macros to take effect.
131 .B F19 
132 will format C code when it is highlighted.  An executable file called 
133 .B ~/.mc/cedit/edit.indent.rc 
134 will be created for you from the default template.  Feel free to edit it
135 if you need.
137 .B C-p 
138 will run ispell on a block of text in a similar way.  The script file
139 will be called
140 .B ~/.mc/cedit/edit.spell.rc
143 .SH Redefining Keys
144 Keys may be redefined from the Midnight Commander options
145 menu.
147 .SH SYNTAX HIGHLIGHTING
148 As of version 3.6.0, \fBcooledit\fP has syntax highlighting.  This means
149 that keywords and contexts (like C comments, string constants, etc)
150 are highlighted in different colors.  The following section explains
151 the format of the file \fB~/.mc/cedit/Syntax\fP.
153 The file \fB~/.mc/cedit/Syntax\fP is rescanned on opening of a any new
154 editor file. The file contains rules for highlighting, each of which is
155 given on a separate line, and define which keywords will be highlighted
156 to what color. The file is also divided into sections, each beginning
157 with a line with the \fBfile\fP command, followed by a regular
158 expression. The regular expression dictates the file name that that set
159 of rules applies to. Following this is a description to be printed on the
160 left of the editor window explaining the file type to the user. A third
161 optional argument is a regular expression to match the first line of
162 text of the file. If either the file name matches, or the first line of text,
163 then those rules will be loaded.
165 A section ends with the start of a new section. Each section is divided
166 into contexts, and each context contains rules. A context is a scope
167 within the text that a particular set of rules belongs to. For instance,
168 the region within a C style comment (i.e. between \fB/*\fP and \fB*/\fP)
169 has its own color. This is a context, although it will have no further
170 rules inside it because there is probably nothing that we want
171 highlighted within a C comment.
173 A trivial C programming section might look like this:
176 file .\\*\\\\.c C\\sProgram\\sFile (#include|/\\\\\\*)
178 wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
180 # default colors
181 context default
182   keyword  whole  if       24
183   keyword  whole  else     24
184   keyword  whole  for      24
185   keyword  whole  while    24
186   keyword  whole  do       24
187   keyword  whole  switch   24
188   keyword  whole  case     24
189   keyword  whole  static   24
190   keyword  whole  extern   24
191   keyword         {        14
192   keyword         }        14
193   keyword         '*'      6 
195 # C comments
196 context /\\* \\*/ 22
198 # C preprocessor directives
199 context linestart # \\n 18
200   keyword  \\\\\\n  24
202 # C string constants
203 context " " 6
204   keyword  %d    24
205   keyword  %s    24
206   keyword  %c    24
207   keyword  \\\\"   24
210 Each context starts with a line of the form:
212 \fBcontext\fP [\fBexclusive\fP] [\fBwhole\fP|\fBwholeright\fP|\fBwholeleft\fP] 
213 [\fBlinestart\fP] \fIdelim\fP [\fBlinestart\fP] \fIdelim\fP [\fIforeground\fP] [\fIbackground\fP]
216 One exception is the first context. It must start with the command
218 \fBcontext\fP \fBdefault\fP [\fIforeground\fP] [\fIbackground\fP]
220 or else \fBcooledit\fP will return an error.
222 The \fBlinestart\fP option dictates that \fIdelim\fP must start at
223 the beginning of a line.
225 The \fBwhole\fP option tells that delim must be a whole word. What
226 constitutes a whole word are a set of characters that can be
227 changed at any point in the file with the \fBwholechars\fP
228 command. The \fBwholechars\fP command at the top just sets the
229 set exactly to its default and could therefore have been omitted. To
230 specify that a word must be whole on the left only, you can use
231 the \fBwholeleft\fP option, and similarly on the right. The left and
232 right set of characters can be set separately with,
234 \fBwholechars\fP [\fBleft\fP|\fBright\fP] \fIcharacters\fP
236 The \fBexclusive\fP option causes the text between the delimiters to be
237 highlighted, but not the delimiters themselves.
239 Each rule is a line of the form:
241 \fBkeyword\fP [\fBwhole\fP|\fBwholeright\fP|\fBwholeleft\fP] [\fBlinestart\fP] 
242 \fIstring\fP \fIforeground\fP [\fIbackground\fP]
245 Context or keyword strings are interpreted, so that you can include
246 tabs and spaces with the sequences \\t and \\s.  Newlines and the \\ are
247 specified with \\n and \\\\ respectively.  Since whitespace is used as a
248 separator, it may not be used as is.  Also, \\* must be used to specify
249 a *.  The * itself is a wildcard that matches any length of characters.
250 For example,
252   keyword         '*'      6 
254 colors all C single character constants green. You could also have
255 used
257   keyword         "*"      6 
259 to color string constants, except that the matched string may not cross
260 newlines. \fIThe wildcard may be used within context delimiters as
261 well\fP, but you \fBcannot have a wildcard as the last or first character\fP.
263 Important to note is the line
265   keyword  \\\\\\n  24
267 This line defines a keyword containing the \\ and newline characters.
268 Because keywords have a higher precedence than context delimiters, this
269 keyword prevents the context from ending at the end of a line if the
270 line ends in a \\ thus allowing C preprocessor directive to continue
271 across multiple lines.
273 The colors themselves are numbered 0 to 26 and are explained below in
274 \fBFURTHER BEHAVIORAL OPTIONS\fP. You can also use \fBany\fP of the named
275 colors specified in \fB/usr/lib/X11/rgb.txt\fP, though only one word
276 versions of them. It is better to stick to the numerical colors
277 to limit use of the color palette.
279 Comments may be included on a line of there own and begin with
280 a #.
282 Because of the simplicity of the implementation, there are a few
283 intricacies that will not be coped with correctly but these are a minor
284 irritation. On the whole, a broad spectrum of quite complicated
285 situations are handled with these simple rules. It is a good idea to
286 take a look at the syntax file to see some of the nifty tricks you can
287 do with a little imagination. If you can't get by with the rules I have
288 coded, and you think you have a rule that would be useful, please email
289 me with your request. However, do not ask for regular expression
290 support, because this is flatly impossible.
292 A useful hint is to work with as much as possible with the things
293 you \fIcan\fP do rather than try to do things that this
294 implementation can't cope with. Also remember that the aim of
295 syntax highlighting is to make programming less prone to error,
296 \fInot\fP to make code look pretty.
298 .SH COLORS
299 The default colors may be changed by appending to the
300 \fBMC_COLOR_TABLE\fP environment variable. Foreground and
301 background colors pairs may be specified for example with:
304 MC_COLOR_TABLE="$MC_COLOR_TABLE:\\
305 editnormal=lightgray,black:\\
306 editbold=yellow,black:\\
307 editmarked=black,cyan"
310 .SH OPTIONS
311 Most options can now be set from the editors options dialog
312 box. See the \fBOptions\fP menu. The following options are defined in 
313 \fB~/.mc/ini\fP and have obvious counterparts in the dialog box.
314 You can modify them to change the editor behavior, by editing the file. 
315 Unless specified, a 1 sets the option to on, and a 0 sets it to
316 off, as is usual.
318 .I use_internal_edit
319 This option is ignored when invoking 
320 .B mcedit.
322 .I editor_key_emulation
323 1 for 
324 .B Emacs 
325 keys, and 0 for normal 
326 .B Cooledit 
327 keys.
329 .I editor_tab_spacing
330 Interpret the tab character as being of this length.
331 Default is 8. You should avoid using
332 other than 8 since most other editors and text viewers
333 assume a tab spacing of 8. Use 
334 .B editor_fake_half_tabs 
335 to simulate a smaller tab spacing.
337 .I editor_fill_tabs_with_spaces
338 Never insert a tab space. Rather insert spaces (ascii 20h) to fill to the
339 desired tab size.
341 .I editor_return_does_auto_indent
342 Pressing return will tab across to match the indentation
343 of the first line above that has text on it.
345 .I editor_backspace_through_tabs
346 Make a single backspace delete all the space to the left
347 margin if there is no text between the cursor and the left
348 margin.
350 .I editor_fake_half_tabs
351 This will emulate a half tab for those who want to program
352 with a tab spacing of 4, but do not want the tab size changed
353 from 8 (so that the code will be formatted the same when displayed
354 by other programs). When editing between text and the left 
355 margin, moving and tabbing will be as though a tab space were
356 4, while actually using spaces and normal tabs for an optimal fill.
357 When editing anywhere else, a normal tab is inserted.
359 .I editor_option_save_mode
360 (0, 1 or 2.) The save mode (see the options menu also)
361 allows you to change the method
362 of saving a file. Quick save (0) saves the file by immediately,
363 truncating the disk file to zero length (i.e. erasing it)
364 and the writing the editor contents to the file. This method
365 is fast, but dangerous, since a system error during a file
366 save will leave the file only partially written, possibly
367 rendering the data irretrievable. When saving, the safe save (1)
368 option enables creation of a temporary file into which the
369 file contents are first written. In the event of an problem,
370 the original file is untouched. When the temporary file is
371 successfully written, it is renamed to the name of the original
372 file, thus replacing it. The safest method is create
373 backups (2). Where a backup file is created before any changes
374 are made. You can specify your own backup file extension in
375 the dialog. Note that saving twice will replace your backup
376 as well as your original file.
378 .SH Miscellaneous
380 (Scanf search and replace have previously not worked properly.
381 With this release, problems with search and replace have been
382 fixed.)
384 You can use scanf search and replace to search and replace
385 a C format string. First take a look at the 
386 .B sscanf 
387 and 
388 .B sprintf 
389 man pages to see what a format string
390 is and how it works. An example is as follows: Suppose you want
391 to replace all occurrences of say, an open bracket, three
392 comma separated numbers, and a close bracket, with the
393 word 
394 .I apples, 
395 the third number, the word 
396 .I oranges
397 and then the second number, you would fill in the Replace dialog
398 box as follows:
401 .B Enter search string
402 (%d,%d,%d)
403 .B Enter replace string
404 apples %d oranges %d
405 .B Enter replacement argument order
409 The last line specifies that the third and then the second
410 number are to be used in place of the first and second.
412 It is advisable to use this feature with Prompt On Replace on, because
413 a match is thought to be found whenever the number of arguments found
414 matches the number given, which is not always a real match. Scanf also
415 treats whitespace as being elastic.  Note that the scanf format %[ is
416 very useful for scanning strings, and whitespace.
418 The editor also displays non-us characters (160+). When editing
419 binary files, you should set 
420 .B display bits 
421 to 7 bits in the Midnight Commander options menu to keep the
422 spacing clean.
425 .SH FILES
426 @prefix@/lib/mc.hlp
428 The help file for the program.
430 @prefix@/lib/mc/mc.ini
432 The default system-wide setup for the Midnight Commander, used only if
433 the user lacks his own ~/.mc/ini file.
435 @prefix@/lib/mc/mc.lib
437 Global settings for the Midnight Commander.  Settings in this file are
438 global to any Midnight Commander, it is useful to define site-global
439 .\"LINK2
440 terminal settings.
441 .\"Terminal databases"
443 $HOME/.mc/ini
445 User's own setup. If this file is present then the setup is loaded
446 from here instead of the system-wide startup file.
448 $HOME/.mc/cedit/
450 User's own temporary directory where block commands are processed
451 and saved.
453 .\"SKIP_SECTION"
454 .SH LICENSE
455 This program is distributed under the terms of the GNU General Public
456 License as published by the Free Software Foundation. See the built-in
457 help of the Midnight Commander for details on the License and the lack
458 of warranty.
459 .SH AVAILABILITY
460 The latest version of this program can be found at 
461 ftp://ftp.gnome.org/mirror/gnome.org/stable/sources/mc/ and on the
462 mirrors listed on the GNOME site http://www.gnome.org/.
463 .SH SEE ALSO
464 cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
466 .SH AUTHORS
467 Paul Sheer (psheer@obsidian.co.za) is the developer of
468 the Midnight Commander's internal editor.
470 .SH BUGS
471 Bugs should be reported to mc-devel@gnome.org