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 requests staring the internal editor and opening 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 the last one will be
25 actual 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. Maximim 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.
191 macros, but in addition the files are untagged. You can use this macro
192 only once per menu file entry or extension file entry, because next time
193 there will be no tagged files.
198 The selected files: The tagged files if there are any. Otherwise the
201 Feel free to edit this files, if you need.
202 Here is a sample external script:
206 TMPFILE=`mktemp ${MC_TMPDIR:\-/tmp}/up.XXXXXX` || exit 1
207 echo #if 0 > $TMPFILE
209 echo #endif >> $TMPFILE
214 If some keys don't work, you can use
221 can be used to navigation through code with tags files created by etags
222 or ctags commands. If there is no file TAGS code navigation would not work.
223 In example, in case of exuberant\-ctags for C language command will be:
225 ctags \-e \-\-language\-force=C \-R ./
228 show list box to select item under cursor (cusor should stand at end of
232 where minus is symbol "\-" go to previous function in navigation list (like a browser
236 where equal is symbol "=" go to next function in navigation list (like a browser
239 .SH SYNTAX HIGHLIGHTING
241 supports syntax highlighting. This means that keywords and contexts
242 (like C comments, string constants, etc) are highlighted in different
243 colors. The following section explains the format of the file
244 .BR ~/.config/mc/mcedit/Syntax .
245 If this file is missing, system\-wide
246 .B %prefix%/share/mc/syntax/Syntax
249 .B ~/.config/mc/mcedit/Syntax
250 is rescanned on opening of a any new editor file. The file contains
251 rules for highlighting, each of which is given on a separate line, and
252 define which keywords will be highlighted to what color.
254 The file is divided into sections, each beginning with a line with the
256 command. The sections are normally put into separate files using the
262 command has three arguments. The first argument is a regular expression
263 that is applied to the file name to determine if the following section
264 applies to the file. The second argument is the description of the file
269 may use it as well. The third optional argument is a regular expression
270 to match the first line of text of the file. The rules in the following
271 section apply if either the file name or the first line of text matches.
273 A section ends with the start of another section. Each section is
274 divided into contexts, and each context contains rules. A context is a
275 scope within the text that a particular set of rules belongs to. For
276 instance, the text within a C style comment (i.e. between
280 has its own color. This is a context, although it has no further rules
281 inside it because there is probably nothing that we want highlighted
284 A trivial C programming section might look like this:
287 file .\\*\\\\.c C\\sProgram\\sFile (#include|/\\\\\\*)
289 wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
294 keyword whole if yellow
295 keyword whole else yellow
296 keyword whole for yellow
297 keyword whole while yellow
298 keyword whole do yellow
299 keyword whole switch yellow
300 keyword whole case yellow
301 keyword whole static yellow
302 keyword whole extern yellow
308 context /\\* \\*/ comment
310 # C preprocessor directives
311 context linestart # \\n red
312 keyword \\\\\\n brightred
316 keyword %d brightgreen
317 keyword %s brightgreen
318 keyword %c brightgreen
319 keyword \\\\" brightgreen
322 Each context starts with a line of the form:
326 .RB [ whole | wholeright | wholeleft ]
335 The first context is an exception. It must start with the command
344 will report an error. The
346 option specifies that
348 must start at the beginning of a line. The
352 must be a whole word. To specify that a word must begin on the word
353 boundary only on the left side, you can use the
355 option, and similarly a word that must end on the word boundary is specified by
358 The set of characters that constitute a whole word can be changed at any
359 point in the file with the
361 command. The left and right set of characters can be set separately
370 option causes the text between the delimiters to be highlighted, but not
371 the delimiters themselves.
373 Each rule is a line of the form:
376 .RB [ whole | wholeright | wholeleft ]
382 Context or keyword strings are interpreted, so that you can include tabs
383 and spaces with the sequences \\t and \\s. Newlines and backslashes are
384 specified with \\n and \\\\ respectively. Since whitespace is used as a
385 separator, it may not be used as is. Also, \\* must be used to specify
386 an asterisk. The * itself is a wildcard that matches any length of
387 characters. For example,
393 colors all C single character constants green. You also could use
399 to color string constants, but the matched string would not be allowed
400 to span across multiple newlines. The wildcard may be used within
401 context delimiters as well, but you cannot have a wildcard as the last
404 Important to note is the line
407 keyword \\\\\\n brightgreen
410 This line defines a keyword containing the backslash and newline
411 characters. Since the keywords are matched before the context
412 delimiters, this keyword prevents the context from ending at the end of
413 the lines that end in a backslash, thus allowing C preprocessor
414 directive to continue across multiple lines.
416 The possible colors are: black, gray, red, brightred, green,
417 brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta,
418 cyan, brightcyan, lightgray and white. The special keyword "default" means
419 the terminal's default. Another special keyword "base" means mc's main
420 colors, it is useful as a placeholder if you want to specify attributes
421 without modifying the background color. When 256 colors are available,
422 they can be specified either as color16 to color255, or as rgb000 to rgb555
425 If the syntax file is shared with
427 it is possible to specify different colors for
431 by separating them with a slash, e.g.
434 keyword #include red/Orange
438 uses the color before the slash. See cooledit(1) for supported
442 Attributes can be any of bold, underline, reverse and blink, appended by a
443 plus sign if more than one are desired.
445 Comments may be put on a separate line starting with the hash sign (#).
447 If you are describing case insensitive language you need to use
449 directive. It should be specified at the beginning of syntax file.
451 Because of the simplicity of the implementation, there are a few
452 intricacies that will not be dealt with correctly but these are a minor
453 irritation. On the whole, a broad spectrum of quite complicated
454 situations are handled with these simple rules. It is a good idea to
455 take a look at the syntax file to see some of the nifty tricks you can
456 do with a little imagination. If you cannot get by with the rules I
457 have coded, and you think you have a rule that would be useful, please
458 email me with your request. However, do not ask for regular expression
459 support, because this is flatly impossible.
461 A useful hint is to work with as much as possible with the things you
462 can do rather than try to do things that this implementation cannot deal
463 with. Also remember that the aim of syntax highlighting is to make
464 programming less prone to error, not to make code look pretty.
466 The syntax highlighting can be toggled using Ctrl\-s shortcut.
468 The default colors may be changed by appending to the
470 environment variable. Foreground and background colors pairs may be
471 specified for example with:
474 MC_COLOR_TABLE="$MC_COLOR_TABLE:\\
475 editnormal=lightgray,black:\\
476 editbold=yellow,black:\\
477 editmarked=black,cyan"
480 Most options can now be set from the editors options dialog box. See
483 menu. The following options are defined in
485 and have obvious counterparts in the dialog box. You can modify them to
486 change the editor behavior, by editing the file. Unless specified, a 1
487 sets the option to on, and a 0 sets it to off, as is usual.
490 This option is ignored when invoking
493 .I editor_tab_spacing
494 Interpret the tab character as being of this length.
495 Default is 8. You should avoid using
496 other than 8 since most other editors and text viewers
497 assume a tab spacing of 8. Use
498 .B editor_fake_half_tabs
499 to simulate a smaller tab spacing.
501 .I editor_fill_tabs_with_spaces
502 Never insert a tab space. Rather insert spaces (ascii 20h) to fill to the
505 .I editor_return_does_auto_indent
506 Pressing return will tab across to match the indentation
507 of the first line above that has text on it.
509 .I editor_backspace_through_tabs
510 Make a single backspace delete all the space to the left
511 margin if there is no text between the cursor and the left
514 .I editor_fake_half_tabs
515 This will emulate a half tab for those who want to program
516 with a tab spacing of 4, but do not want the tab size changed
517 from 8 (so that the code will be formatted the same when displayed
518 by other programs). When editing between text and the left
519 margin, moving and tabbing will be as though a tab space were
520 4, while actually using spaces and normal tabs for an optimal fill.
521 When editing anywhere else, a normal tab is inserted.
523 .I editor_option_save_mode
524 Possible values 0, 1 and 2. The save mode (see the options menu also)
525 allows you to change the method of saving a file. Quick save (0) saves
526 the file by immediately, truncating the disk file to zero length (i.e.
527 erasing it) and the writing the editor contents to the file. This
528 method is fast, but dangerous, since a system error during a file save
529 will leave the file only partially written, possibly rendering the data
530 irretrievable. When saving, the safe save (1) option enables creation
531 of a temporary file into which the file contents are first written. In
532 the event of an problem, the original file is untouched. When the
533 temporary file is successfully written, it is renamed to the name of the
534 original file, thus replacing it. The safest method is create backups
535 (2). Where a backup file is created before any changes are made. You
536 can specify your own backup file extension in the dialog. Note that
537 saving twice will replace your backup as well as your original file.
539 .I editor_word_wrap_line_length
540 line length to wrap. 72 default.
542 .I editor_backup_extension
543 symbol for add extension to name of backup files. Default "~".
546 show state line of editor now it show number of file line (in future it
547 can show things like folding, breakpoints, etc.). M\-n toglle this option.
549 .I editor_visible_spaces
550 Toggle show visible trailing spaces (TWS), if editor_visible_spaces=1 TWS
553 .I editor_visible_tabs
554 Toggle show visible tabs, if editor_visible_tabs=1 tabs showed as '<\-\-\-\->'
556 .I editor_persistent_selections
557 Do not remove block selection after moving the cursor.
559 .I editor_cursor_beyond_eol
560 Allow moving cursor beyond the end of line.
562 .I editor_cursor_after_inserted_block
563 Allow moving cursor after inserted block.
565 .I editor_syntax_highlighting
566 enable syntax highlighting.
568 .I editor_edit_confirm_save
569 show confirm dialog on save.
571 .I editor_option_typewriter_wrap
574 .I editor_option_auto_para_formatting
577 .I editor_option_save_position
578 save file position on exit.
581 symbol representation of codepage name for file (i.e. CP1251, ~ \- default).
584 do UNDO for several of the same type of action (inserting/overwriting,
585 deleting, navigating, typing)
587 .I editor_wordcompletion_collect_entire_file
588 Search autocomplete candidates in entire of file or just from
589 begin of file to cursor position (0)
592 Spelling language (en, en\-variant_0, ru, etc) installed with aspell
593 package (a full list can be get using 'aspell' utility).
595 .B spell_language = NONE
596 to disable aspell support. Default value is 'en'. Option must located
597 in the [Misc] section.
599 You can use scanf search and replace to search and replace a C format
600 string. First take a look at the
604 man pages to see what a format string is and how it works. Here's an
605 example: suppose that you want to replace all occurrences of an open
606 bracket, three comma separated numbers, and a close bracket, with the
609 the third number, the word
611 and then the second number. You would fill in the Replace dialog box as
615 .B Enter search string
617 .B Enter replace string
619 .B Enter replacement argument order
623 The last line specifies that the third and then the second number are to
624 be used in place of the first and second.
626 It is advisable to use this feature with Prompt On Replace on, because a
627 match is thought to be found whenever the number of arguments found
628 matches the number given, which is not always a real match. Scanf also
629 treats whitespace as being elastic. Note that the scanf format %[ is
630 very useful for scanning strings, and whitespace.
632 The editor also displays non\-us characters (160+). When editing
633 binary files, you should set
635 to 7 bits in the Midnight Commander options menu to keep the spacing
638 .I %prefix%/share/mc/mc.hlp
640 The help file for the program.
642 .I %prefix%/share/mc/mc.ini
644 The default system\-wide setup for GNU Midnight Commander, used only if
645 the user's own ~/.config/mc/ini file is missing.
647 .I %prefix%/share/mc/mc.lib
649 Global settings for the Midnight Commander. Settings in this file
650 affect all users, whether they have ~/.config/mc/ini or not.
652 .I %prefix%/share/mc/syntax/*
654 The default system\-wide syntax files for mcedit, used only if
655 the corresponding user's own ~/.local/share/mc/mcedit/ file is missing.
659 User's own setup. If this file is present then the setup is loaded
660 from here instead of the system\-wide setup file.
662 .I ~/.local/share/mc/mcedit/
664 User's own directory where block commands are processed and saved and
665 user's own syntax files are located.
667 This program is distributed under the terms of the GNU General Public
668 License as published by the Free Software Foundation. See the built\-in
669 help of the Midnight Commander for details on the License and the lack
672 The latest version of this program can be found at
673 http://ftp.midnight\-commander.org/.
675 cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
677 Paul Sheer (psheer@obsidian.co.za) is the original author of
678 the Midnight Commander's internal editor.
680 Bugs should be reported to http://www.midnight\-commander.org/.