1 .TH MCEDIT 1 "September 2007" "MC Version 4.6.2-pre1" "GNU Midnight Commander"
3 mcedit \- Internal file editor of GNU Midnight Commander.
6 [\-bcCdfhstVx?] [+lineno] file
9 [\-bcCdfhstVx?] file:lineno[:]
14 the main GNU Midnight Commander executable. Executing GNU Midnight
15 Commander under this name requests staring the internal editor and
18 specified on the command line. The editor is based on the terminal
21 \- standalone editor for X Window System.
25 Go to the line specified by number (do not put a space between the
30 Force black and white display.
33 Force ANSI color mode on terminals that don't seem to have color
36 .I "\-C <keyword>=<FGcolor>,<BGcolor>:<keyword>= ..."
37 Specify a different color set. See the
39 section in mc(1) for more information.
42 Disable mouse support.
45 Display the compiled-in search path for GNU Midnight Commander data
49 Force using termcap database instead of terminfo. This option is only
50 applicable if GNU Midnight Commander was compiled with S-Lang library
51 with terminfo support.
54 Display the version of the program.
57 Force xterm mode. Used when running on xterm-capable terminals (two
58 screen modes, and able to send mouse escape sequences).
60 The internal file editor is a full-featured full screen editor. It can
61 edit files up to 64 megabytes. It is possible to edit binary files.
62 The features it presently supports are: block copy, move, delete, cut,
63 paste; key for key undo; pull-down menus; file insertion; macro
64 commands; regular expression search and replace (and our own
65 scanf-printf search and replace); shift-arrow text highlighting (if
66 supported by the terminal); insert-overwrite toggle; word wrap;
67 autoindent; tunable tab size; syntax highlighting for various file
68 types; and an option to pipe text blocks through shell commands like
71 The editor is easy to use and can be used without learning. The
72 pull-down menu is invoked by pressing F9. You can learn other keys from
73 the menu and from the button bar labels.
75 In addition to that, Shift combined with arrows does text highlighting
76 (if supported by the terminal):
79 .BR ~/.mc/cedit/cooledit.clip ,
82 .BR ~/.mc/cedit/cooledit.clip ,
85 .BR ~/.mc/cedit/cooledit.clip ,
88 deletes highlighted text. Mouse highlighting also works on some
89 terminals. To use the standard mouse support provided by your terminal,
90 hold the Shift key. Please note that the mouse support in the terminal
91 doesn't share the clipboard with
94 The completion key (usually
98 completes the word under the cursor using the words used earlier in the
101 To define a macro, press
103 and then type out the keys you want to be executed. Press
105 again when finished. You can then assign the macro to any key you like
106 by pressing that key. The macro is executed when you press
108 and then the assigned key. The macro is also executed if you press
109 Meta, Ctrl, or Esc and the assigned key, provided that the key is not
110 used for any other function. The macro commands are stored in the file
111 .BR ~/.mc/cedit/cooledit.macros .
112 Do NOT edit this file if you are going to use macros again in the same
113 editing session, because
115 caches macro key defines in memory.
117 now overwrites a macro if a macro with the same key already exists,
118 so you won't have to edit this file. You will also have to restart
119 other running editors for macros to take effect.
122 will format C, C++, Java or HTML code when it is highlighted. An executable
124 .B ~/.mc/cedit/edit.indent.rc
125 will be created for you from the default template. Feel free to edit it
129 will run ispell on a block of text in a similar way. The script file
131 .BR ~/.mc/cedit/edit.spell.rc .
133 If some keys don't work, you can use
138 .SH SYNTAX HIGHLIGHTING
140 supports syntax highlighting. This means that keywords and contexts
141 (like C comments, string constants, etc) are highlighted in different
142 colors. The following section explains the format of the file
143 .BR ~/.mc/cedit/Syntax .
144 If this file is missing, system-wide
145 .B @prefix@/share/mc/syntax/Syntax
148 .B ~/.mc/cedit/Syntax
149 is rescanned on opening of a any new editor file. The file contains
150 rules for highlighting, each of which is given on a separate line, and
151 define which keywords will be highlighted to what color.
153 The file is divided into sections, each beginning with a line with the
155 command. The sections are normally put into separate files using the
161 command has three arguments. The first argument is a regular expression
162 that is applied to the file name to determine if the following section
163 applies to the file. The second argument is the description of the file
168 may use it as well. The third optional argument is a regular expression
169 to match the first line of text of the file. The rules in the following
170 section apply if either the file name or the first line of text matches.
172 A section ends with the start of another section. Each section is
173 divided into contexts, and each context contains rules. A context is a
174 scope within the text that a particular set of rules belongs to. For
175 instance, the text within a C style comment (i.e. between
179 has its own color. This is a context, although it has no further rules
180 inside it because there is probably nothing that we want highlighted
183 A trivial C programming section might look like this:
186 file .\\*\\\\.c C\\sProgram\\sFile (#include|/\\\\\\*)
188 wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
193 keyword whole if yellow
194 keyword whole else yellow
195 keyword whole for yellow
196 keyword whole while yellow
197 keyword whole do yellow
198 keyword whole switch yellow
199 keyword whole case yellow
200 keyword whole static yellow
201 keyword whole extern yellow
207 context /\\* \\*/ comment
209 # C preprocessor directives
210 context linestart # \\n red
211 keyword \\\\\\n brightred
215 keyword %d brightgreen
216 keyword %s brightgreen
217 keyword %c brightgreen
218 keyword \\\\" brightgreen
221 Each context starts with a line of the form:
225 .RB [ whole | wholeright | wholeleft ]
233 The first context is an exception. It must start with the command
241 will report an error. The
243 option specifies that
245 must start at the beginning of a line. The
249 must be a whole word. To specify that a word must begin on the word
250 boundary only on the left side, you can use the
252 option, and similarly a word that must end on the word boundary is specified by
255 The set of characters that constitute a whole word can be changed at any
256 point in the file with the
258 command. The left and right set of characters can be set separately
267 option causes the text between the delimiters to be highlighted, but not
268 the delimiters themselves.
270 Each rule is a line of the form:
273 .RB [ whole | wholeright | wholeleft ]
278 Context or keyword strings are interpreted, so that you can include tabs
279 and spaces with the sequences \\t and \\s. Newlines and backslashes are
280 specified with \\n and \\\\ respectively. Since whitespace is used as a
281 separator, it may not be used as is. Also, \\* must be used to specify
282 an asterisk. The * itself is a wildcard that matches any length of
283 characters. For example,
289 colors all C single character constants green. You also could use
295 to color string constants, but the matched string would not be allowed
296 to span across multiple newlines. The wildcard may be used within
297 context delimiters as well, but you cannot have a wildcard as the last
300 Important to note is the line
303 keyword \\\\\\n brightgreen
306 This line defines a keyword containing the backslash and newline
307 characters. Since the keywords are matched before the context
308 delimiters, this keyword prevents the context from ending at the end of
309 the lines that end in a backslash, thus allowing C preprocessor
310 directive to continue across multiple lines.
312 The possible colors are: black, gray, red, brightred, green,
313 brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta,
314 cyan, brightcyan, lightgray and white. If the syntax file is shared
317 it is possible to specify different colors for
321 by separating them with a slash, e.g.
324 keyword #include red/Orange
328 uses the color before the slash. See cooledit(1) for supported
332 Comments may be put on a separate line starting with the hash sign (#).
334 Because of the simplicity of the implementation, there are a few
335 intricacies that will not be dealt with correctly but these are a minor
336 irritation. On the whole, a broad spectrum of quite complicated
337 situations are handled with these simple rules. It is a good idea to
338 take a look at the syntax file to see some of the nifty tricks you can
339 do with a little imagination. If you cannot get by with the rules I
340 have coded, and you think you have a rule that would be useful, please
341 email me with your request. However, do not ask for regular expression
342 support, because this is flatly impossible.
344 A useful hint is to work with as much as possible with the things you
345 can do rather than try to do things that this implementation cannot deal
346 with. Also remember that the aim of syntax highlighting is to make
347 programming less prone to error, not to make code look pretty.
349 The default colors may be changed by appending to the
351 environment variable. Foreground and background colors pairs may be
352 specified for example with:
355 MC_COLOR_TABLE="$MC_COLOR_TABLE:\\
356 editnormal=lightgray,black:\\
357 editbold=yellow,black:\\
358 editmarked=black,cyan"
361 Most options can now be set from the editors options dialog box. See
364 menu. The following options are defined in
366 and have obvious counterparts in the dialog box. You can modify them to
367 change the editor behavior, by editing the file. Unless specified, a 1
368 sets the option to on, and a 0 sets it to off, as is usual.
371 This option is ignored when invoking
374 .I editor_key_emulation
377 keys, and 0 for normal
381 .I editor_tab_spacing
382 Interpret the tab character as being of this length.
383 Default is 8. You should avoid using
384 other than 8 since most other editors and text viewers
385 assume a tab spacing of 8. Use
386 .B editor_fake_half_tabs
387 to simulate a smaller tab spacing.
389 .I editor_fill_tabs_with_spaces
390 Never insert a tab space. Rather insert spaces (ascii 20h) to fill to the
393 .I editor_return_does_auto_indent
394 Pressing return will tab across to match the indentation
395 of the first line above that has text on it.
397 .I editor_backspace_through_tabs
398 Make a single backspace delete all the space to the left
399 margin if there is no text between the cursor and the left
402 .I editor_fake_half_tabs
403 This will emulate a half tab for those who want to program
404 with a tab spacing of 4, but do not want the tab size changed
405 from 8 (so that the code will be formatted the same when displayed
406 by other programs). When editing between text and the left
407 margin, moving and tabbing will be as though a tab space were
408 4, while actually using spaces and normal tabs for an optimal fill.
409 When editing anywhere else, a normal tab is inserted.
411 .I editor_option_save_mode
412 Possible values 0, 1 and 2. The save mode (see the options menu also)
413 allows you to change the method of saving a file. Quick save (0) saves
414 the file by immediately, truncating the disk file to zero length (i.e.
415 erasing it) and the writing the editor contents to the file. This
416 method is fast, but dangerous, since a system error during a file save
417 will leave the file only partially written, possibly rendering the data
418 irretrievable. When saving, the safe save (1) option enables creation
419 of a temporary file into which the file contents are first written. In
420 the event of an problem, the original file is untouched. When the
421 temporary file is successfully written, it is renamed to the name of the
422 original file, thus replacing it. The safest method is create backups
423 (2). Where a backup file is created before any changes are made. You
424 can specify your own backup file extension in the dialog. Note that
425 saving twice will replace your backup as well as your original file.
427 You can use scanf search and replace to search and replace a C format
428 string. First take a look at the
432 man pages to see what a format string is and how it works. Here's an
433 example: suppose that you want to replace all occurrences of an open
434 bracket, three comma separated numbers, and a close bracket, with the
437 the third number, the word
439 and then the second number. You would fill in the Replace dialog box as
443 .B Enter search string
445 .B Enter replace string
447 .B Enter replacement argument order
451 The last line specifies that the third and then the second number are to
452 be used in place of the first and second.
454 It is advisable to use this feature with Prompt On Replace on, because a
455 match is thought to be found whenever the number of arguments found
456 matches the number given, which is not always a real match. Scanf also
457 treats whitespace as being elastic. Note that the scanf format %[ is
458 very useful for scanning strings, and whitespace.
460 The editor also displays non-us characters (160+). When editing
461 binary files, you should set
463 to 7 bits in the Midnight Commander options menu to keep the spacing
466 .I @prefix@/share/mc/mc.hlp
468 The help file for the program.
470 .I @prefix@/share/mc/mc.ini
472 The default system-wide setup for GNU Midnight Commander, used only if
473 the user's own ~/.mc/ini file is missing.
475 .I @prefix@/share/mc/mc.lib
477 Global settings for the Midnight Commander. Settings in this file
478 affect all users, whether they have ~/.mc/ini or not.
480 .I @prefix@/share/mc/syntax/*
482 The default system-wide syntax files for mcedit, used only if
483 the corresponding user's own ~/.mc/cedit/ file is missing.
487 User's own setup. If this file is present then the setup is loaded
488 from here instead of the system-wide setup file.
492 User's own directory where block commands are processed and saved and
493 user's own syntax files are located.
495 This program is distributed under the terms of the GNU General Public
496 License as published by the Free Software Foundation. See the built-in
497 help of the Midnight Commander for details on the License and the lack
500 The latest version of this program can be found at
501 ftp://ftp.gnu.org/gnu/mc/.
503 cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
505 Paul Sheer (psheer@obsidian.co.za) is the original author of
506 the Midnight Commander's internal editor.
508 Bugs should be reported to mc-devel@gnome.org