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] [file1] [file2] ...
9 [\-bcCdfhstVx?] file1:lineno[:] file2:lineno[:] ...
14 the main GNU Midnight Commander executable. Executing GNU Midnight Commander
15 under this name runs the internal editor and opens files
16 specified on the command line. The editor is based on the terminal version of
18 \- standalone editor for X Window System.
22 Go to the line specified by number (do not put a space between the
24 sign and the number). Several line numbers are allowed but only the last one
25 will be used, and it will be applied to the first file only.
28 Force black and white display.
31 Force ANSI color mode on terminals that don't seem to have color
34 .I "\-C <keyword>=<fgcolor>,<bgcolor>,<attributes>:<keyword>= ..."
35 Specify a different color set. See the
37 section in mc(1) for more information.
40 Disable mouse support.
43 Display the compiled\-in search path for GNU Midnight Commander data
47 Force using termcap database instead of terminfo. This option is only
48 applicable if GNU Midnight Commander was compiled with S\-Lang library
49 with terminfo support.
52 Display the version of the program.
55 Force xterm mode. Used when running on xterm\-capable terminals (two
56 screen modes, and able to send mouse escape sequences).
58 The internal file editor is a full\-featured windowed editor. It can
59 edit several files at the same time. Maximum size of each file is 64
60 megabytes. It is possible to edit binary files. The features it presently
61 supports are: block copy, move, delete, cut, paste; key for key undo;
62 pull\-down menus; file insertion; macro commands; regular expression
63 search and replace; shift\-arrow text highlighting (if supported by
64 the terminal); insert\-overwrite toggle; autoindent; tunable tab size;
65 syntax highlighting for various file types; and an option to pipe text
66 blocks through shell commands like indent and ispell.
68 Each file is opened in its own window in full\-screen mode. Window control
69 in mcedit is similar to the window control in other multi\-window program:
70 double click on window title maximizes the window to full\-screen or restores
71 window size and position; left\-click on window title and mouse drag moves
72 the window in editor area; left\-click on low\-right frame corner and mouse drag
73 resizes the window. These actions can be made using "Window" menu.
75 The editor is easy to use and can be used without learning. The
76 pull\-down menu is invoked by pressing F9. You can learn other keys from
77 the menu and from the button bar labels.
79 In addition to that, Shift combined with arrows does text highlighting
80 (if supported by the terminal):
83 .BR ~/.cache/mc/mcedit/mcedit.clip ,
86 .BR ~/.cache/mc/mcedit/mcedit.clip ,
89 .BR ~/.cache/mc/mcedit/mcedit.clip ,
92 deletes highlighted text. Mouse highlighting also works on some
93 terminals. To use the standard mouse support provided by your terminal,
94 hold the Shift key. Please note that the mouse support in the terminal
95 doesn't share the clipboard with
98 The completion key (usually
102 completes the word under the cursor using the words used in the file.
105 To define a macro, press
107 and then type out the keys you want to be executed. Press
109 again when finished. The macro can be assigned to any key by pressing that key.
110 The macro is executed when you press the assigned key.
112 The macro commands are stored in section
115 .BR ~/.local/share/mc/mc.macros .
117 External scripts (filters) can be assigned into the any hotkey by edit
123 ctrl\-W=ExecuteScript:25;
126 This means that ctrl\-W hotkey initiates the
128 action, then editor handler translates this into execution of
129 .B ~/.local/share/mc/mcedit/macros.d/macro.25.sh
132 External scripts are stored in
133 .B ~/.local/share/mc/mcedit/macros.d/
134 directory and must be named as
138 is the number from 0 to 9999.
141 for more detail about format of the script.
143 Following macro definition and directives can be used:
146 If this directive is set, then script starts without interactive subshell.
149 The cursor column position number.
152 The indent of blank space, equal the cursor column.
155 The syntax type of current file.
161 The current file name.
164 Only the current file name without extension.
167 The extension of current file name.
170 The current directory name.
173 The current file in the unselected panel.
176 The directory name of the unselected panel.
179 The currently tagged files.
182 The tagged files in the unselected panel.
189 macros, but in addition the files are untagged. You can use this macro
190 only once per menu file entry or extension file entry, because next time
191 there will be no tagged files.
194 The selected files: The tagged files if there are any. Otherwise the
197 Feel free to edit this files, if you need.
198 Here is a sample external script:
202 TMPFILE=`mktemp ${MC_TMPDIR:\-/tmp}/up.XXXXXX` || exit 1
203 echo #if 0 > $TMPFILE
205 echo #endif >> $TMPFILE
210 If some keys don't work, you can use
217 can be used for navigation through code with tags files created by etags
218 or ctags commands. If there is no TAGS file code navigation will not work.
219 For example, in case of exuberant\-ctags for C language command will be:
221 ctags \-e \-\-language\-force=C \-R ./
224 shows list box to select item under cursor (cursor should stand at the end
228 where minus is symbol "\-" goes to previous function in navigation list
229 (like browser's Back button).
232 where equal is symbol "=" goes to next function in navigation list
233 (like browser's Forward button).
235 .SH SYNTAX HIGHLIGHTING
237 supports syntax highlighting. This means that keywords and contexts
238 (like C comments, string constants, etc) are highlighted in different
239 colors. The following section explains the format of the file
240 .BR ~/.config/mc/mcedit/Syntax .
241 If this file is missing, system\-wide
242 .B %prefix%/share/mc/syntax/Syntax
245 .B ~/.config/mc/mcedit/Syntax
246 is rescanned on opening of every new editor file. The file contains
247 rules for highlighting, each of which is given on a separate line, and
248 define which keywords will be highlighted with what color.
250 The file is divided into sections, each beginning with a line with the
252 command. The sections are normally put into separate files using the
258 command has three arguments. The first argument is a regular expression
259 that is applied to the file name to determine if the following section
260 applies to the file. The second argument is the description of the file
265 may use it as well. The third optional argument is a regular expression
266 to match the first line of text of the file. The rules in the following
267 section apply if either the file name or the first line of text matches.
269 A section ends with the start of another section. Each section is
270 divided into contexts, and each context contains rules. A context is a
271 scope within the text that a particular set of rules belongs to. For
272 instance, the text within a C style comment (i.e. between
276 has its own color. This is a context, although it has no further rules
277 inside it because there is probably nothing that we want highlighted
280 A trivial C programming section might look like this:
283 file .\\*\\\\.c C\\sProgram\\sFile (#include|/\\\\\\*)
285 wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
290 keyword whole if yellow
291 keyword whole else yellow
292 keyword whole for yellow
293 keyword whole while yellow
294 keyword whole do yellow
295 keyword whole switch yellow
296 keyword whole case yellow
297 keyword whole static yellow
298 keyword whole extern yellow
304 context /\\* \\*/ comment
306 # C preprocessor directives
307 context linestart # \\n red
308 keyword \\\\\\n brightred
312 keyword %d brightgreen
313 keyword %s brightgreen
314 keyword %c brightgreen
315 keyword \\\\" brightgreen
318 Each context starts with a line of the form:
322 .RB [ whole | wholeright | wholeleft ]
331 The first context is an exception. It must start with the command
340 will report an error. The
342 option specifies that
344 must start at the beginning of a line. The
348 must be a whole word. To specify that a word must begin on the word
349 boundary only on the left side, you can use the
351 option, and similarly a word that must end on the word boundary is specified by
354 The set of characters that constitute a whole word can be changed at any
355 point in the file with the
357 command. The left and right set of characters can be set separately
366 option causes the text between the delimiters to be highlighted, but not
367 the delimiters themselves.
369 Each rule is a line of the form:
372 .RB [ whole | wholeright | wholeleft ]
378 Context or keyword strings are interpreted, so that you can include tabs
379 and spaces with the sequences \\t and \\s. Newlines and backslashes are
380 specified with \\n and \\\\ respectively. Since whitespace is used as a
381 separator, it may not be used as is. Also, \\* must be used to specify
382 an asterisk. The * itself is a wildcard that matches any length of
383 characters. For example,
389 colors all C single character constants green. You also could use
395 to color string constants, but the matched string would not be allowed
396 to span across multiple newlines. The wildcard may be used within
397 context delimiters as well, but you cannot have a wildcard as the last
400 Important to note is the line
403 keyword \\\\\\n brightgreen
406 This line defines a keyword containing the backslash and newline
407 characters. Since the keywords are matched before the context
408 delimiters, this keyword prevents the context from ending at the end of
409 the lines that end in a backslash, thus allowing C preprocessor
410 directive to continue across multiple lines.
412 The possible colors are: black, gray, red, brightred, green,
413 brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta,
414 cyan, brightcyan, lightgray and white. The special keyword "default" means
415 the terminal's default. Another special keyword "base" means mc's main
416 colors, it is useful as a placeholder if you want to specify attributes
417 without modifying the background color. When 256 colors are available,
418 they can be specified either as color16 to color255, or as rgb000 to rgb555
421 If the syntax file is shared with
423 it is possible to specify different colors for
427 by separating them with a slash, e.g.
430 keyword #include red/Orange
434 uses the color before the slash. See cooledit(1) for supported
438 Attributes can be any of bold, italic, underline, reverse and blink, appended by a
439 plus sign if more than one are desired.
441 Comments may be put on a separate line starting with the hash sign (#).
443 If you are describing case insensitive language you need to use
445 directive. It should be specified at the beginning of syntax file.
447 Because of the simplicity of the implementation, there are a few
448 intricacies that will not be dealt with correctly but these are a minor
449 irritation. On the whole, a broad spectrum of quite complicated
450 situations are handled with these simple rules. It is a good idea to
451 take a look at the syntax file to see some of the nifty tricks you can
452 do with a little imagination. If you cannot get by with the rules I
453 have coded, and you think you have a rule that would be useful, please
454 email me with your request. However, do not ask for regular expression
455 support, because this is flatly impossible.
457 A useful hint is to work with as much as possible with the things you
458 can do rather than try to do things that this implementation cannot deal
459 with. Also remember that the aim of syntax highlighting is to make
460 programming less prone to error, not to make code look pretty.
462 The syntax highlighting can be toggled using Ctrl\-s shortcut.
464 The default colors may be changed by appending to the
466 environment variable. Foreground and background colors pairs may be
467 specified for example with:
470 MC_COLOR_TABLE="$MC_COLOR_TABLE:\\
471 editnormal=lightgray,black:\\
472 editbold=yellow,black:\\
473 editmarked=black,cyan"
476 Most options can be set from Options dialog box. See the
478 menu. The following options are defined in
480 and have obvious counterparts in the dialog box. You can modify them to
481 change the editor behavior, by editing the file. Unless specified, a 1
482 sets the option to on, and a 0 sets it to off, as usual.
485 This option is ignored when invoking
488 .I editor_tab_spacing
489 Interpret the tab character as being of this length.
490 Default is 8. You should avoid using
491 other than 8 since most other editors and text viewers
492 assume a tab spacing of 8. Use
493 .B editor_fake_half_tabs
494 to simulate a smaller tab spacing.
496 .I editor_fill_tabs_with_spaces
497 Never insert a tab character. Rather insert spaces (ascii 32) to fill to the
500 .I editor_return_does_auto_indent
501 Pressing return will tab across to match the indentation
502 of the first line above that has text on it.
504 .I editor_backspace_through_tabs
505 Make a single backspace delete all the space to the left
506 margin if there is no text between the cursor and the left
509 .I editor_fake_half_tabs
510 This will emulate a half tab for those who want to program
511 with a tab spacing of 4, but do not want the tab size changed
512 from 8 (so that the code will be formatted the same when displayed
513 by other programs). When editing between text and the left
514 margin, moving and tabbing will be as though a tab space were
515 4, while actually using spaces and normal tabs for an optimal fill.
516 When editing anywhere else, a normal tab is inserted.
518 .I editor_option_save_mode
519 Possible values 0, 1 and 2. The save mode (see the options menu also)
520 allows you to change the method of saving a file. Quick save (0) saves
521 the file immediately, truncating the disk file to zero length (i.e.
522 erasing it) and then writing the editor contents to the file. This
523 method is fast, but dangerous, since a system error during a file save
524 will leave the file only partially written, possibly rendering the data
525 irretrievable. When saving, the safe save (1) option enables creation
526 of a temporary file into which the file contents are first written. In
527 the event of a problem, the original file is untouched. When the
528 temporary file is successfully written, it is renamed to the name of the
529 original file, thus replacing it. The safest method is create backups
530 (2): a backup file is created before any changes are made. You
531 can specify your own backup file extension in the dialog. Note that
532 saving twice will replace your backup as well as your original file.
534 .I editor_word_wrap_line_length
535 Line length to wrap at. Default is 72.
537 .I editor_backup_extension
538 Symbol to add to name of backup files. Default is "~".
541 Show state line of editor. Currently it shows current line number (in the future
542 it might show things like folding, breakpoints, etc.). M\-n toggles this option.
544 .I editor_visible_spaces
545 Toggle "show visible trailing spaces". If editor_visible_spaces=1, they are shown
548 .I editor_visible_tabs
549 Toggle "show visible tabs". If editor_visible_tabs=1, tabs are shown as '<\-\-\-\->'
551 .I editor_persistent_selections
552 Do not remove block selection after cursor movement.
554 .I editor_drop_selection_on_copy
555 Reset selection after copy to clipboard.
557 .I editor_cursor_beyond_eol
558 Allow moving cursor beyond the end of line.
560 .I editor_cursor_after_inserted_block
561 Allow moving cursor after inserted block.
563 .I editor_syntax_highlighting
564 enable syntax highlighting.
566 .I editor_edit_confirm_save
567 Show confirmation dialog on save.
569 .I editor_option_typewriter_wrap
572 .I editor_option_auto_para_formatting
575 .I editor_option_save_position
576 Save file position on exit.
579 Symbol representation of codepage name for file (i.e. CP1251, ~ \- default).
582 Combine UNDO actions for several of the same type of action (inserting/overwriting,
583 deleting, navigating, typing)
585 .I editor_wordcompletion_collect_entire_file
586 Search autocomplete candidates in entire file (1) or just from
587 beginning of file to cursor position (0).
590 Spelling language (en, en\-variant_0, ru, etc) installed with aspell
591 package (a full list can be obtained using 'aspell' utility).
593 .B spell_language = NONE
594 to disable aspell support. Default value is 'en'. Option must be located
595 in the [Misc] section.
597 .I editor_stop_format_chars
598 Set of characters to stop paragraph formatting. If one of those characters
599 is found in the beginning of line, that line and all following lines of paragraph
600 will be untouched. Default value is
601 "\fB-\fR\fB+\fR\fB*\fR\fB\\\fR\fB,\fR\fB.\fR\fB;\fR\fB:\fR\fB&\fR\fB>\fR".
603 .I editor_state_full_filename
604 Show full path name in the status line. If disabled (default), only base name of the
607 You can use scanf search and replace to search and replace a C format
608 string. First take a look at the
612 man pages to see what a format string is and how it works. Here's an
613 example: suppose that you want to replace all occurrences of an open
614 bracket, three comma separated numbers, and a close bracket, with the
617 the third number, the word
619 and then the second number. You would fill in the Replace dialog box as
623 .B Enter search string
625 .B Enter replace string
627 .B Enter replacement argument order
631 The last line specifies that the third and then the second number are to
632 be used in place of the first and second.
634 It is advisable to use this feature with Prompt On Replace on, because a
635 match is thought to be found whenever the number of arguments found
636 matches the number given, which is not always a real match. Scanf also
637 treats whitespace as being elastic. Note that the scanf format %[ is
638 very useful for scanning strings, and whitespace.
640 The editor also displays non\-us characters (160+). When editing
641 binary files, you should set
643 to 7 bits in Midnight Commander's options menu to keep the spacing
646 .I %prefix%/share/mc/help/mc.hlp
648 The help file for the program.
650 .I %prefix%/share/mc/mc.ini
652 The default system\-wide setup for GNU Midnight Commander, used only if
653 the user's own ~/.config/mc/ini file is missing.
655 .I %prefix%/share/mc/mc.lib
657 Global settings for Midnight Commander. Settings in this file
658 affect all users, whether they have ~/.config/mc/ini or not.
660 .I %prefix%/share/mc/syntax/*
662 The default system\-wide syntax files for mcedit, used only if
663 the corresponding user's own ~/.local/share/mc/mcedit/ file is missing.
667 User's own setup. If this file is present then the setup is loaded
668 from here instead of the system\-wide setup file.
670 .I ~/.local/share/mc/mcedit/
672 User's own directory where block commands are processed and saved and
673 user's own syntax files are located.
675 This program is distributed under the terms of the GNU General Public
676 License as published by the Free Software Foundation. See the built\-in
677 help of Midnight Commander for details on the License and the lack
680 The latest version of this program can be found at
681 http://ftp.midnight\-commander.org/.
683 cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
685 Paul Sheer (psheer@obsidian.co.za) is the original author of
686 Midnight Commander's internal editor.
688 Bugs should be reported to http://www.midnight\-commander.org/.