Updated italian translation
[midnight-commander.git] / doc / mcedit.1.in
blob4fc76e88523113fb447719e87e666eb83f4c5b3f
1 .TH MCEDIT 1 "January 2003" "MC Version 4.6.0" "GNU Midnight Commander"
2 .SH NAME
3 mcedit \- Internal file editor of GNU Midnight Commander.
4 .SH USAGE
5 .B mcedit
6 [\-bcCdfhstVx?] [+number] file
7 .SH DESCRIPTION
8 .LP
9 mcedit is a link to
10 .BR mc ,
11 the main GNU Midnight Commander executable.  Executing GNU Midnight
12 Commander under this name requests staring the internal editor and
13 opening the
14 .I file
15 specified on the command line.  The editor is based on the terminal
16 version of
17 .B cooledit
18 \- standalone editor for X Window System.
19 .SH OPTIONS
20 .TP
21 .I "+number"
22 Go  to the line specified by number (do not put a space between the
23 .I "+"
24 sign and the number).
25 .TP
26 .I "\-b"
27 Force black and white display.
28 .TP
29 .I "\-c"
30 Force ANSI color mode on terminals that don't seem to have color
31 support.
32 .TP
33 .I "\-C <keyword>=<FGcolor>,<BGcolor>:<keyword>= ..."
34 Specify a different color set.  See the
35 .B Colors
36 section in mc(1) for more information.
37 .TP
38 .I "\-d"
39 Disable mouse support.
40 .TP
41 .I "\-f"
42 Display the compiled-in search path for GNU Midnight Commander data
43 files.
44 .TP
45 .I "\-t"
46 Force using termcap database instead of terminfo.  This option is only
47 applicable if GNU Midnight Commander was compiled with S-Lang library
48 with terminfo support.
49 .TP
50 .I "\-V"
51 Display the version of the program.
52 .TP
53 .I "\-x"
54 Force xterm mode.  Used when running on xterm-capable terminals (two
55 screen modes, and able to send mouse escape sequences).
56 .SH FEATURES
57 The internal file editor is a full-featured full screen editor.  It can
58 edit files up to 64 megabytes.  It is possible to edit binary files. 
59 The features it presently supports are: block copy, move, delete, cut,
60 paste; key for key undo; pull-down menus; file insertion; macro
61 commands; regular expression search and replace (and our own
62 scanf-printf search and replace); shift-arrow text highlighting (if
63 supported by the terminal); insert-overwrite toggle; word wrap;
64 autoindent; tunable tab size; syntax highlighting for various file
65 types; and an option to pipe text blocks through shell commands like
66 indent and ispell.
67 .SH KEYS
68 The editor is easy to use and can be used without learning.  The
69 pull-down menu is invoked by pressing F9.  You can learn other keys from
70 the menu and from the button bar labels.
71 .PP
72 In addition to that, Shift combined with arrows does text highlighting
73 (if supported by the terminal):
74 .B Ctrl-Ins
75 copies to the file
76 .BR ~/.mc/cedit/cooledit.clip ,
77 .B Shift-Ins
78 pastes from
79 .BR ~/.mc/cedit/cooledit.clip ,
80 .B Shift-Del
81 cuts to
82 .BR ~/.mc/cedit/cooledit.clip ,
83 and
84 .B Ctrl-Del
85 deletes highlighted text.  Mouse highlighting also works on some
86 terminals.  To use the standard mouse support provided by your terminal,
87 hold the Shift key.  Please note that the mouse support in the terminal
88 doesn't share the clipboard with
89 .BR mcedit .
90 .PP
91 The completion key (usually
92 .B "Alt-Tab"
94 .BR "Escape Tab" )
95 completes the word under the cursor using the words used earlier in the
96 file.
97 .PP
98 To define a macro, press
99 .B Ctrl-R
100 and then type out the keys you want to be executed.  Press
101 .B Ctrl-R
102 again when finished.  You can then assign the macro to any key you like
103 by pressing that key.  The macro is executed when you press
104 .B Ctrl-A
105 and then the assigned key.  The macro is also executed if you press
106 Meta, Ctrl, or Esc and the assigned key, provided that the key is not
107 used for any other function.  The macro commands are stored in the file
108 .BR ~/.mc/cedit/cooledit.macros .
109 Do NOT edit this file if you are going to use macros again in the same
110 editing session, because
111 .B mcedit
112 caches macro key defines in memory.
113 .B mcedit
114 now overwrites a macro if a macro with the same key already exists,
115 so you won't have to edit this file. You will also have to restart
116 other running editors for macros to take effect.
118 .B F19
119 will format C, C++, Java or HTML code when it is highlighted.  An executable
120 file called
121 .B ~/.mc/cedit/edit.indent.rc
122 will be created for you from the default template.  Feel free to edit it
123 if you need.
125 .B C-p
126 will run ispell on a block of text in a similar way.  The script file
127 will be called
128 .BR ~/.mc/cedit/edit.spell.rc .
130 If some keys don't work, you can use
131 .B Learn Keys
132 in the
133 .B Options
134 menu.
135 .SH SYNTAX HIGHLIGHTING
136 .B mcedit
137 supports syntax highlighting.  This means that keywords and contexts
138 (like C comments, string constants, etc) are highlighted in different
139 colors.  The following section explains the format of the file
140 .BR ~/.mc/cedit/Syntax .
141 If this file is missing, system-wide
142 .B @prefix@/share/mc/syntax/Syntax
143 is used.
144 The file
145 .B ~/.mc/cedit/Syntax
146 is rescanned on opening of a any new editor file.  The file contains
147 rules for highlighting, each of which is given on a separate line, and
148 define which keywords will be highlighted to what color.
150 The file is divided into sections, each beginning with a line with the
151 .B file
152 command.  The sections are normally put into separate files using the
153 .B include
154 command.
157 .B file
158 command has three arguments.  The first argument is a regular expression
159 that is applied to the file name to determine if the following section
160 applies to the file.  The second argument is the description of the file
161 type.  It is used in
162 .BR cooledit ;
163 future versions of
164 .B mcedit
165 may use it as well.  The third optional argument is a regular expression
166 to match the first line of text of the file.  The rules in the following
167 section apply if either the file name or the first line of text matches.
169 A section ends with the start of another section.  Each section is
170 divided into contexts, and each context contains rules.  A context is a
171 scope within the text that a particular set of rules belongs to.  For
172 instance, the text within a C style comment (i.e. between
173 .B /*
175 .BR */ )
176 has its own color.  This is a context, although it has no further rules
177 inside it because there is probably nothing that we want highlighted
178 within a C comment.
180 A trivial C programming section might look like this:
183 file .\\*\\\\.c C\\sProgram\\sFile (#include|/\\\\\\*)
185 wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
187 # default colors
188 define  comment   brown
189 context default
190   keyword  whole  if       yellow
191   keyword  whole  else     yellow
192   keyword  whole  for      yellow
193   keyword  whole  while    yellow
194   keyword  whole  do       yellow
195   keyword  whole  switch   yellow
196   keyword  whole  case     yellow
197   keyword  whole  static   yellow
198   keyword  whole  extern   yellow
199   keyword         {        brightcyan
200   keyword         }        brightcyan
201   keyword         '*'      green
203 # C comments
204 context /\\* \\*/ comment
206 # C preprocessor directives
207 context linestart # \\n red
208   keyword  \\\\\\n  brightred
210 # C string constants
211 context " " green
212   keyword  %d    brightgreen
213   keyword  %s    brightgreen
214   keyword  %c    brightgreen
215   keyword  \\\\"   brightgreen
218 Each context starts with a line of the form:
220 .B context
221 .RB [ exclusive ]
222 .RB [ whole | wholeright | wholeleft ]
223 .RB [ linestart ]
224 .I delim
225 .RB [ linestart ]
226 .I delim
227 .RI [ foreground ]
228 .RI [ background ]
230 The first context is an exception.  It must start with the command
232 .B context default
233 .RI [ foreground ]
234 .RI [ background ]
236 otherwise
237 .B mcedit
238 will report an error.  The
239 .B linestart
240 option specifies that
241 .I delim
242 must start at the beginning of a line.  The
243 .B whole
244 option tells that
245 .I delim
246 must be a whole word.  To specify that a word must begin on the word
247 boundary only on the left side, you can use the
248 .B wholeleft
249 option, and similarly a word that must end on the word boundary is specified by
250 .BR wholeright .
252 The set of characters that constitute a whole word can be changed at any
253 point in the file with the
254 .B wholechars
255 command.  The left and right set of characters can be set separately
256 with
258 .B wholechars
259 .RB [ left | right ]
260 .I characters
263 .B exclusive
264 option causes the text between the delimiters to be highlighted, but not
265 the delimiters themselves.
267 Each rule is a line of the form:
269 .B keyword
270 .RB [ whole | wholeright | wholeleft ]
271 .RB [ linestart ]
272 .I string foreground
273 .RI [ background ]
275 Context or keyword strings are interpreted, so that you can include tabs
276 and spaces with the sequences \\t and \\s.  Newlines and backslashes are
277 specified with \\n and \\\\ respectively.  Since whitespace is used as a
278 separator, it may not be used as is.  Also, \\* must be used to specify
279 an asterisk.  The * itself is a wildcard that matches any length of
280 characters.  For example,
283   keyword         '*'      green
286 colors all C single character constants green.  You also could use
289   keyword         "*"      green
292 to color string constants, but the matched string would not be allowed
293 to span across multiple newlines.  The wildcard may be used within
294 context delimiters as well, but you cannot have a wildcard as the last
295 or first character.
297 Important to note is the line
300   keyword  \\\\\\n  brightgreen
303 This line defines a keyword containing the backslash and newline
304 characters.  Since the keywords are matched before the context
305 delimiters, this keyword prevents the context from ending at the end of
306 the lines that end in a backslash, thus allowing C preprocessor
307 directive to continue across multiple lines.
309 The possible colors are: black, gray, red, brightred, green,
310 brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta,
311 cyan, brightcyan, lightgray and white.  If the syntax file is shared
312 with
313 .BR cooledit ,
314 it is possible to specify different colors for
315 .B mcedit
317 .B cooledit
318 by separating them with a slash, e.g.
321 keyword  #include  red/Orange
324 .B mcedit
325 uses the color before the slash.  See cooledit(1) for supported
326 .B cooledit
327 colors.
329 Comments may be put on a separate line starting with the hash sign (#).
331 Because of the simplicity of the implementation, there are a few
332 intricacies that will not be dealt with correctly but these are a minor
333 irritation.  On the whole, a broad spectrum of quite complicated
334 situations are handled with these simple rules.  It is a good idea to
335 take a look at the syntax file to see some of the nifty tricks you can
336 do with a little imagination.  If you cannot get by with the rules I
337 have coded, and you think you have a rule that would be useful, please
338 email me with your request.  However, do not ask for regular expression
339 support, because this is flatly impossible.
341 A useful hint is to work with as much as possible with the things you
342 can do rather than try to do things that this implementation cannot deal
343 with.  Also remember that the aim of syntax highlighting is to make
344 programming less prone to error, not to make code look pretty.
345 .SH COLORS
346 The default colors may be changed by appending to the
347 .B MC_COLOR_TABLE
348 environment variable.  Foreground and background colors pairs may be
349 specified for example with:
352 MC_COLOR_TABLE="$MC_COLOR_TABLE:\\
353 editnormal=lightgray,black:\\
354 editbold=yellow,black:\\
355 editmarked=black,cyan"
357 .SH OPTIONS
358 Most options can now be set from the editors options dialog box.  See
360 .B Options
361 menu.  The following options are defined in
362 .B ~/.mc/ini
363 and have obvious counterparts in the dialog box.  You can modify them to
364 change the editor behavior, by editing the file.  Unless specified, a 1
365 sets the option to on, and a 0 sets it to off, as is usual.
367 .I use_internal_edit
368 This option is ignored when invoking
369 .BR mcedit .
371 .I editor_key_emulation
372 1 for
373 .B Emacs
374 keys, and 0 for normal
375 .B Cooledit
376 keys.
378 .I editor_tab_spacing
379 Interpret the tab character as being of this length.
380 Default is 8. You should avoid using
381 other than 8 since most other editors and text viewers
382 assume a tab spacing of 8. Use
383 .B editor_fake_half_tabs
384 to simulate a smaller tab spacing.
386 .I editor_fill_tabs_with_spaces
387 Never insert a tab space. Rather insert spaces (ascii 20h) to fill to the
388 desired tab size.
390 .I editor_return_does_auto_indent
391 Pressing return will tab across to match the indentation
392 of the first line above that has text on it.
394 .I editor_backspace_through_tabs
395 Make a single backspace delete all the space to the left
396 margin if there is no text between the cursor and the left
397 margin.
399 .I editor_fake_half_tabs
400 This will emulate a half tab for those who want to program
401 with a tab spacing of 4, but do not want the tab size changed
402 from 8 (so that the code will be formatted the same when displayed
403 by other programs). When editing between text and the left
404 margin, moving and tabbing will be as though a tab space were
405 4, while actually using spaces and normal tabs for an optimal fill.
406 When editing anywhere else, a normal tab is inserted.
408 .I editor_option_save_mode
409 Possible values 0, 1 and 2.  The save mode (see the options menu also)
410 allows you to change the method of saving a file.  Quick save (0) saves
411 the file by immediately, truncating the disk file to zero length (i.e.
412 erasing it) and the writing the editor contents to the file.  This
413 method is fast, but dangerous, since a system error during a file save
414 will leave the file only partially written, possibly rendering the data
415 irretrievable.  When saving, the safe save (1) option enables creation
416 of a temporary file into which the file contents are first written.  In
417 the event of an problem, the original file is untouched.  When the
418 temporary file is successfully written, it is renamed to the name of the
419 original file, thus replacing it.  The safest method is create backups
420 (2).  Where a backup file is created before any changes are made.  You
421 can specify your own backup file extension in the dialog.  Note that
422 saving twice will replace your backup as well as your original file.
423 .SH MISCELLANEOUS
424 You can use scanf search and replace to search and replace a C format
425 string.  First take a look at the
426 .B sscanf
428 .B sprintf
429 man pages to see what a format string is and how it works.  Here's an
430 example: suppose that you want to replace all occurrences of an open
431 bracket, three comma separated numbers, and a close bracket, with the
432 word
433 .IR apples ,
434 the third number, the word
435 .I oranges
436 and then the second number.  You would fill in the Replace dialog box as
437 follows:
440 .B Enter search string
441 (%d,%d,%d)
442 .B Enter replace string
443 apples %d oranges %d
444 .B Enter replacement argument order
448 The last line specifies that the third and then the second number are to
449 be used in place of the first and second.
451 It is advisable to use this feature with Prompt On Replace on, because a
452 match is thought to be found whenever the number of arguments found
453 matches the number given, which is not always a real match. Scanf also
454 treats whitespace as being elastic.  Note that the scanf format %[ is
455 very useful for scanning strings, and whitespace.
457 The editor also displays non-us characters (160+).  When editing
458 binary files, you should set
459 .B display bits
460 to 7 bits in the Midnight Commander options menu to keep the spacing
461 clean.
462 .SH FILES
463 .I @prefix@/share/mc/mc.hlp
465 The help file for the program.
467 .I @prefix@/share/mc/mc.ini
469 The default system-wide setup for GNU Midnight Commander, used only if
470 the user's own ~/.mc/ini file is missing.
472 .I @prefix@/share/mc/mc.lib
474 Global settings for the Midnight Commander.  Settings in this file
475 affect all users, whether they have ~/.mc/ini or not.
477 .I @prefix@/share/mc/syntax/*
479 The default system-wide syntax files for mcedit, used only if
480 the corresponding user's own ~/.mc/cedit/ file is missing.
482 .I $HOME/.mc/ini
484 User's own setup.  If this file is present then the setup is loaded
485 from here instead of the system-wide setup file.
487 .I $HOME/.mc/cedit/
489 User's own directory where block commands are processed and saved and
490 user's own syntax files are located.
491 .SH LICENSE
492 This program is distributed under the terms of the GNU General Public
493 License as published by the Free Software Foundation.  See the built-in
494 help of the Midnight Commander for details on the License and the lack
495 of warranty.
496 .SH AVAILABILITY
497 The latest version of this program can be found at
498 ftp://ftp.ibiblio.org/pub/Linux/utils/file/managers/mc/.
499 .SH SEE ALSO
500 cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
501 .SH AUTHORS
502 Paul Sheer (psheer@obsidian.co.za) is the original author of
503 the Midnight Commander's internal editor.
504 .SH BUGS
505 Bugs should be reported to mc-devel@gnome.org