1 .TH MCEDIT 1 "@DATE_OF_MAN_PAGE@" "MC Version @DISTR_VERSION@" "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>,<attributes>:<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 ~/.cache/mc/mcedit/mcedit.clip ,
82 .BR ~/.cache/mc/mcedit/mcedit.clip ,
85 .BR ~/.cache/mc/mcedit/mcedit.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
102 To define a macro, press
104 and then type out the keys you want to be executed. Press
106 again when finished. The macro can be assigned to any key by pressing that key.
107 The macro is executed when you press the assigned key.
109 The macro commands are stored in section
112 .BR ~/.local/share/mc/mc.macros .
114 External scripts (filters) can be assigned into the any hotkey by edit
120 ctrl\-W=ExecuteScript:25;
123 This means that ctrl\-W hotkey initiates the
125 action, then editor handler translates this into execution of
126 .B ~/.local/share/mc/mcedit/macros.d/macro.25.sh
129 External scripts are stored in
130 .B ~/.local/share/mc/mcedit/macros.d/
131 directory and must be named as
135 is the number from 0 to 9999.
138 for more detail about format of the script.
140 Following macro definition and directives can be used:
143 If this directive is set, then script starts without interactive subshell.
146 The cursor column position number.
149 The indent of blank space, equal the cursor column.
152 The syntax type of current file.
158 The current file name.
161 Only the current file name without extension.
164 The extension of current file name.
167 The current directory name.
170 The current file in the unselected panel.
173 The directory name of the unselected panel.
176 The currently tagged files.
179 The tagged files in the unselected panel.
188 macros, but in addition the files are untagged. You can use this macro
189 only once per menu file entry or extension file entry, because next time
190 there will be no tagged files.
195 The selected files: The tagged files if there are any. Otherwise the
198 Feel free to edit this files, if you need.
199 Here is a sample external script:
203 TMPFILE=`mktemp ${MC_TMPDIR:\-/tmp}/up.XXXXXX` || exit 1
204 echo #if 0 > $TMPFILE
206 echo #endif >> $TMPFILE
211 If some keys don't work, you can use
218 can be used to navigation through code with tags files created by etags
219 or ctags commands. If there is no file TAGS code navigation would not work.
220 In example, in case of exuberant\-ctags for C language command will be:
222 ctags \-e \-\-language\-force=C \-R ./
225 show list box to select item under cursor (cusor should stand at end of
229 where minus is symbol "\-" go to previous function in navigation list (like a browser
233 where equal is symbol "=" go to next function in navigation list (like a browser
236 .SH SYNTAX HIGHLIGHTING
238 supports syntax highlighting. This means that keywords and contexts
239 (like C comments, string constants, etc) are highlighted in different
240 colors. The following section explains the format of the file
241 .BR ~/.local/share/mc/mcedit/Syntax .
242 If this file is missing, system\-wide
243 .B @prefix@/share/mc/syntax/Syntax
246 .B ~/.local/share/mc/mcedit/Syntax
247 is rescanned on opening of a any new editor file. The file contains
248 rules for highlighting, each of which is given on a separate line, and
249 define which keywords will be highlighted to what color.
251 The file is divided into sections, each beginning with a line with the
253 command. The sections are normally put into separate files using the
259 command has three arguments. The first argument is a regular expression
260 that is applied to the file name to determine if the following section
261 applies to the file. The second argument is the description of the file
266 may use it as well. The third optional argument is a regular expression
267 to match the first line of text of the file. The rules in the following
268 section apply if either the file name or the first line of text matches.
270 A section ends with the start of another section. Each section is
271 divided into contexts, and each context contains rules. A context is a
272 scope within the text that a particular set of rules belongs to. For
273 instance, the text within a C style comment (i.e. between
277 has its own color. This is a context, although it has no further rules
278 inside it because there is probably nothing that we want highlighted
281 A trivial C programming section might look like this:
284 file .\\*\\\\.c C\\sProgram\\sFile (#include|/\\\\\\*)
286 wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
291 keyword whole if yellow
292 keyword whole else yellow
293 keyword whole for yellow
294 keyword whole while yellow
295 keyword whole do yellow
296 keyword whole switch yellow
297 keyword whole case yellow
298 keyword whole static yellow
299 keyword whole extern yellow
305 context /\\* \\*/ comment
307 # C preprocessor directives
308 context linestart # \\n red
309 keyword \\\\\\n brightred
313 keyword %d brightgreen
314 keyword %s brightgreen
315 keyword %c brightgreen
316 keyword \\\\" brightgreen
319 Each context starts with a line of the form:
323 .RB [ whole | wholeright | wholeleft ]
332 The first context is an exception. It must start with the command
341 will report an error. The
343 option specifies that
345 must start at the beginning of a line. The
349 must be a whole word. To specify that a word must begin on the word
350 boundary only on the left side, you can use the
352 option, and similarly a word that must end on the word boundary is specified by
355 The set of characters that constitute a whole word can be changed at any
356 point in the file with the
358 command. The left and right set of characters can be set separately
367 option causes the text between the delimiters to be highlighted, but not
368 the delimiters themselves.
370 Each rule is a line of the form:
373 .RB [ whole | wholeright | wholeleft ]
379 Context or keyword strings are interpreted, so that you can include tabs
380 and spaces with the sequences \\t and \\s. Newlines and backslashes are
381 specified with \\n and \\\\ respectively. Since whitespace is used as a
382 separator, it may not be used as is. Also, \\* must be used to specify
383 an asterisk. The * itself is a wildcard that matches any length of
384 characters. For example,
390 colors all C single character constants green. You also could use
396 to color string constants, but the matched string would not be allowed
397 to span across multiple newlines. The wildcard may be used within
398 context delimiters as well, but you cannot have a wildcard as the last
401 Important to note is the line
404 keyword \\\\\\n brightgreen
407 This line defines a keyword containing the backslash and newline
408 characters. Since the keywords are matched before the context
409 delimiters, this keyword prevents the context from ending at the end of
410 the lines that end in a backslash, thus allowing C preprocessor
411 directive to continue across multiple lines.
413 The possible colors are: black, gray, red, brightred, green,
414 brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta,
415 cyan, brightcyan, lightgray and white. The special keyword "default" means
416 the terminal's default. Another special keyword "base" means mc's main
417 colors, it is useful as a placeholder if you want to specify attributes
418 without modifying the background color. When 256 colors are available,
419 they can be specified either as color16 to color255, or as rgb000 to rgb555
422 If the syntax file is shared with
424 it is possible to specify different colors for
428 by separating them with a slash, e.g.
431 keyword #include red/Orange
435 uses the color before the slash. See cooledit(1) for supported
439 Attributes can be any of bold, underline, reverse and blink, appended by a
440 plus sign if more than one are desired.
442 Comments may be put on a separate line starting with the hash sign (#).
444 If you are describing case insensitive language you need to use
446 derective. It should be specified at the begining of syntax file.
448 Because of the simplicity of the implementation, there are a few
449 intricacies that will not be dealt with correctly but these are a minor
450 irritation. On the whole, a broad spectrum of quite complicated
451 situations are handled with these simple rules. It is a good idea to
452 take a look at the syntax file to see some of the nifty tricks you can
453 do with a little imagination. If you cannot get by with the rules I
454 have coded, and you think you have a rule that would be useful, please
455 email me with your request. However, do not ask for regular expression
456 support, because this is flatly impossible.
458 A useful hint is to work with as much as possible with the things you
459 can do rather than try to do things that this implementation cannot deal
460 with. Also remember that the aim of syntax highlighting is to make
461 programming less prone to error, not to make code look pretty.
463 The syntax highlighting can be toggled using Ctrl\-s shortcut.
465 The default colors may be changed by appending to the
467 environment variable. Foreground and background colors pairs may be
468 specified for example with:
471 MC_COLOR_TABLE="$MC_COLOR_TABLE:\\
472 editnormal=lightgray,black:\\
473 editbold=yellow,black:\\
474 editmarked=black,cyan"
477 Most options can now be set from the editors options dialog box. See
480 menu. The following options are defined in
482 and have obvious counterparts in the dialog box. You can modify them to
483 change the editor behavior, by editing the file. Unless specified, a 1
484 sets the option to on, and a 0 sets it to off, as is usual.
487 This option is ignored when invoking
490 .I editor_tab_spacing
491 Interpret the tab character as being of this length.
492 Default is 8. You should avoid using
493 other than 8 since most other editors and text viewers
494 assume a tab spacing of 8. Use
495 .B editor_fake_half_tabs
496 to simulate a smaller tab spacing.
498 .I editor_fill_tabs_with_spaces
499 Never insert a tab space. Rather insert spaces (ascii 20h) to fill to the
502 .I editor_return_does_auto_indent
503 Pressing return will tab across to match the indentation
504 of the first line above that has text on it.
506 .I editor_backspace_through_tabs
507 Make a single backspace delete all the space to the left
508 margin if there is no text between the cursor and the left
511 .I editor_fake_half_tabs
512 This will emulate a half tab for those who want to program
513 with a tab spacing of 4, but do not want the tab size changed
514 from 8 (so that the code will be formatted the same when displayed
515 by other programs). When editing between text and the left
516 margin, moving and tabbing will be as though a tab space were
517 4, while actually using spaces and normal tabs for an optimal fill.
518 When editing anywhere else, a normal tab is inserted.
520 .I editor_option_save_mode
521 Possible values 0, 1 and 2. The save mode (see the options menu also)
522 allows you to change the method of saving a file. Quick save (0) saves
523 the file by immediately, truncating the disk file to zero length (i.e.
524 erasing it) and the writing the editor contents to the file. This
525 method is fast, but dangerous, since a system error during a file save
526 will leave the file only partially written, possibly rendering the data
527 irretrievable. When saving, the safe save (1) option enables creation
528 of a temporary file into which the file contents are first written. In
529 the event of an problem, the original file is untouched. When the
530 temporary file is successfully written, it is renamed to the name of the
531 original file, thus replacing it. The safest method is create backups
532 (2). Where a backup file is created before any changes are made. You
533 can specify your own backup file extension in the dialog. Note that
534 saving twice will replace your backup as well as your original file.
536 .I editor_word_wrap_line_length
537 line length to wrap. 72 default.
539 .I editor_backup_extension
540 symbol for add extension to name of backup files. Default "~".
543 show state line of editor now it show number of file line (in future it
544 can show things like folding, breakpoints, etc.). M\-n toglle this option.
546 .I editor_visible_spaces
547 Toggle show visible trailing spaces (TWS), if editor_visible_spaces=1 TWS
550 .I editor_visible_tabs
551 Toggle show visible tabs, if editor_visible_tabs=1 tabs showed as '<\-\-\-\->'
553 .I editor_persistent_selections
554 Do not remove block selection after moving the cursor.
556 .I editor_cursor_beyond_eol
557 Allow moving cursor beyond the end of line.
559 .I editor_syntax_highlighting
560 enable syntax highlighting.
562 .I editor_edit_confirm_save
563 show confirm dialog on save.
565 .I editor_option_typewriter_wrap
568 .I editor_option_auto_para_formatting
571 .I editor_option_save_position
572 save file position on exit.
575 symbol representation of codepage name for file (i.e. CP1251, ~ \- default).
578 do UNDO for several of the same type of action (inserting/overwriting,
579 deleting, navigating, typing)
581 .I editor_wordcompletion_collect_entire_file
582 Search autocomplete candidates in entire of file or just from
583 begin of file to cursor position (0)
586 You can use scanf search and replace to search and replace a C format
587 string. First take a look at the
591 man pages to see what a format string is and how it works. Here's an
592 example: suppose that you want to replace all occurrences of an open
593 bracket, three comma separated numbers, and a close bracket, with the
596 the third number, the word
598 and then the second number. You would fill in the Replace dialog box as
602 .B Enter search string
604 .B Enter replace string
606 .B Enter replacement argument order
610 The last line specifies that the third and then the second number are to
611 be used in place of the first and second.
613 It is advisable to use this feature with Prompt On Replace on, because a
614 match is thought to be found whenever the number of arguments found
615 matches the number given, which is not always a real match. Scanf also
616 treats whitespace as being elastic. Note that the scanf format %[ is
617 very useful for scanning strings, and whitespace.
619 The editor also displays non\-us characters (160+). When editing
620 binary files, you should set
622 to 7 bits in the Midnight Commander options menu to keep the spacing
625 .I @prefix@/share/mc/mc.hlp
627 The help file for the program.
629 .I @prefix@/share/mc/mc.ini
631 The default system\-wide setup for GNU Midnight Commander, used only if
632 the user's own ~/.config/mc/ini file is missing.
634 .I @prefix@/share/mc/mc.lib
636 Global settings for the Midnight Commander. Settings in this file
637 affect all users, whether they have ~/.config/mc/ini or not.
639 .I @prefix@/share/mc/syntax/*
641 The default system\-wide syntax files for mcedit, used only if
642 the corresponding user's own ~/.local/share/mc/mcedit/ file is missing.
646 User's own setup. If this file is present then the setup is loaded
647 from here instead of the system\-wide setup file.
649 .I ~/.local/share/mc/mcedit/
651 User's own directory where block commands are processed and saved and
652 user's own syntax files are located.
654 This program is distributed under the terms of the GNU General Public
655 License as published by the Free Software Foundation. See the built\-in
656 help of the Midnight Commander for details on the License and the lack
659 The latest version of this program can be found at
660 http://midnight\-commander.org/.
662 cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
664 Paul Sheer (psheer@obsidian.co.za) is the original author of
665 the Midnight Commander's internal editor.
667 Bugs should be reported to mc\-devel@gnome.org