doc: man pages fixes
[midnight-commander.git] / doc / man / mcedit.1.in
blob8a04497349b9c02a20fd649edebbbd52952761c0
1 .TH MCEDIT 1 "%DATE_OF_MAN_PAGE%" "MC Version %DISTR_VERSION%" "GNU Midnight Commander"
2 .SH NAME
3 mcedit \- Internal file editor of GNU Midnight Commander.
4 .SH USAGE
5 .B mcedit
6 [\-bcCdfhstVx?] [+lineno] [file1] [file2] ...
7 .PP
8 .B mcedit
9 [\-bcCdfhstVx?] file1:lineno[:] file2:lineno[:] ...
10 .SH DESCRIPTION
11 .LP
12 mcedit is a link to
13 .BR mc ,
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
17 .B cooledit
18 \- standalone editor for X Window System.
19 .SH OPTIONS
20 .TP
21 .I "+lineno"
22 Go to the line specified by number (do not put a space between the
23 .I "+"
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.
26 .TP
27 .I "\-b"
28 Force black and white display.
29 .TP
30 .I "\-c"
31 Force ANSI color mode on terminals that don't seem to have color
32 support.
33 .TP
34 .I "\-C <keyword>=<fgcolor>,<bgcolor>,<attributes>:<keyword>= ..."
35 Specify a different color set.  See the
36 .B Colors
37 section in mc(1) for more information.
38 .TP
39 .I "\-d"
40 Disable mouse support.
41 .TP
42 .I "\-f"
43 Display the compiled\-in search path for GNU Midnight Commander data
44 files.
45 .TP
46 .I "\-t"
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.
50 .TP
51 .I "\-V"
52 Display the version of the program.
53 .TP
54 .I "\-x"
55 Force xterm mode.  Used when running on xterm\-capable terminals (two
56 screen modes, and able to send mouse escape sequences).
57 .SH FEATURES
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.
67 .PP
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.
74 .SH KEYS
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.
78 .PP
79 In addition to that, Shift combined with arrows does text highlighting
80 (if supported by the terminal):
81 .B Ctrl\-Ins
82 copies to the file
83 .BR ~/.cache/mc/mcedit/mcedit.clip ,
84 .B Shift\-Ins
85 pastes from
86 .BR ~/.cache/mc/mcedit/mcedit.clip ,
87 .B Shift\-Del
88 cuts to
89 .BR ~/.cache/mc/mcedit/mcedit.clip ,
90 and
91 .B Ctrl\-Del
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
96 .BR mcedit .
97 .PP
98 The completion key (usually
99 .B "Meta\-Tab"
101 .BR "Escape Tab" )
102 completes the word under the cursor using the words used in the file.
103 .SH MACRO
105 To define a macro, press
106 .B Ctrl\-R
107 and then type out the keys you want to be executed.  Press
108 .B Ctrl\-R
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
113 .B [editor]
114 it the file
115 .BR ~/.local/share/mc/mc.macros .
117 External scripts (filters) can be assigned into the any hotkey by edit
118 .B mc.macros
119 like following:
122 [editor]
123 ctrl\-W=ExecuteScript:25;
126 This means that ctrl\-W hotkey initiates the
127 .I ExecuteScript(25)
128 action, then editor handler translates this into execution of
129 .B ~/.local/share/mc/mcedit/macros.d/macro.25.sh
130 shell script.
132 External scripts are stored in
133 .B ~/.local/share/mc/mcedit/macros.d/
134 directory and must be named as
135 .B macro.XXXX.sh
136 where
137 .B XXXX
138 is the number from 0 to 9999.
140 .B Edit Menu File
141 for more detail about format of the script.
143 Following macro definition and directives can be used:
145 .I #silent
146 If this directive is set, then script starts without interactive subshell.
148 .I %c
149 The cursor column position number.
151 .I %i
152 The indent of blank space, equal the cursor column.
154 .I %y
155 The syntax type of current file.
157 .I %b
158 The block file name.
160 .I %f
161 The current file name.
163 .I %n
164 Only the current file name without extension.
166 .I %x
167 The extension of current file name.
169 .I %d
170 The current directory name.
172 .I %F
173 The current file in the unselected panel.
175 .I %D
176 The directory name of the unselected panel.
178 .I %t
179 The currently tagged files.
181 .I %T
182 The tagged files in the unselected panel.
184 .IR %u " and " %U
185 Similar to the
186 .I %t
188 .I %T
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.
193 .IR %s " and " %S
194 The selected files: The tagged files if there are any. Otherwise the
195 current file.
197 Feel free to edit this files, if you need.
198 Here is a sample external script:
201 l       comment selection
202         TMPFILE=`mktemp ${MC_TMPDIR:\-/tmp}/up.XXXXXX` || exit 1
203         echo #if 0 > $TMPFILE
204         cat %b >> $TMPFILE
205         echo #endif >> $TMPFILE
206         cat $TMPFILE > %b
207         rm \-f $TMPFILE
210 If some keys don't work, you can use
211 .B Learn Keys
212 in the
213 .B Options
214 menu.
215 .SH CODE NAVIGATION
216 .B mcedit
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 ./
223 .B Meta\-Enter
224 shows list box to select item under cursor (cursor should stand at the end
225 of the word).
227 .B Meta\-Minus
228 where minus is symbol "\-" goes to previous function in navigation list
229 (like browser's Back button).
231 .B Meta\-Equal
232 where equal is symbol "=" goes to next function in navigation list
233 (like browser's Forward button).
235 .SH SYNTAX HIGHLIGHTING
236 .B mcedit
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
243 is used.
244 The file
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
251 .B file
252 command.  The sections are normally put into separate files using the
253 .B include
254 command.
257 .B file
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
261 type.  It is used in
262 .BR cooledit ;
263 future versions of
264 .B mcedit
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
273 .B /*
275 .BR */ )
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
278 within a C comment.
280 A trivial C programming section might look like this:
283 file .\\*\\\\.c C\\sProgram\\sFile (#include|/\\\\\\*)
285 wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
287 # default colors
288 define  comment   brown
289 context default
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
299   keyword         {        brightcyan
300   keyword         }        brightcyan
301   keyword         '*'      green
303 # C comments
304 context /\\* \\*/ comment
306 # C preprocessor directives
307 context linestart # \\n red
308   keyword  \\\\\\n  brightred
310 # C string constants
311 context " " green
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:
320 .B context
321 .RB [ exclusive ]
322 .RB [ whole | wholeright | wholeleft ]
323 .RB [ linestart ]
324 .I delim
325 .RB [ linestart ]
326 .I delim
327 .RI [ foreground ]
328 .RI [ background ]
329 .RI [ attributes ]
331 The first context is an exception.  It must start with the command
333 .B context default
334 .RI [ foreground ]
335 .RI [ background ]
336 .RI [ attributes ]
338 otherwise
339 .B mcedit
340 will report an error.  The
341 .B linestart
342 option specifies that
343 .I delim
344 must start at the beginning of a line.  The
345 .B whole
346 option tells that
347 .I delim
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
350 .B wholeleft
351 option, and similarly a word that must end on the word boundary is specified by
352 .BR wholeright .
354 The set of characters that constitute a whole word can be changed at any
355 point in the file with the
356 .B wholechars
357 command.  The left and right set of characters can be set separately
358 with
360 .B wholechars
361 .RB [ left | right ]
362 .I characters
365 .B exclusive
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:
371 .B keyword
372 .RB [ whole | wholeright | wholeleft ]
373 .RB [ linestart ]
374 .I string foreground
375 .RI [ background ]
376 .RI [ attributes ]
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,
386   keyword         '*'      green
389 colors all C single character constants green.  You also could use
392   keyword         "*"      green
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
398 or first character.
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
419 and gray0 to gray23.
421 If the syntax file is shared with
422 .BR cooledit ,
423 it is possible to specify different colors for
424 .B mcedit
426 .B cooledit
427 by separating them with a slash, e.g.
430 keyword  #include  red/Orange
433 .B mcedit
434 uses the color before the slash.  See cooledit(1) for supported
435 .B cooledit
436 colors.
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
444 .B caseinsensitive
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.
463 .SH COLORS
464 The default colors may be changed by appending to the
465 .B MC_COLOR_TABLE
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"
475 .SH OPTIONS
476 Most options can be set from Options dialog box.  See the
477 .B Options
478 menu.  The following options are defined in
479 .B ~/.config/mc/ini
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.
484 .I use_internal_edit
485 This option is ignored when invoking
486 .BR mcedit .
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
498 desired tab size.
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
507 margin.
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 "~".
540 .I editor_line_state
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
546 as '.'
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
570 to be described
572 .I editor_option_auto_para_formatting
573 to be described
575 .I editor_option_save_position
576 Save file position on exit.
578 .I source_codepage
579 Symbol representation of codepage name for file (i.e. CP1251, ~ \- default).
581 .I editor_group_undo
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).
589 .I spell_language
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
605 file is shown.
606 .SH MISCELLANEOUS
607 You can use scanf search and replace to search and replace a C format
608 string.  First take a look at the
609 .B sscanf
611 .B sprintf
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
615 word
616 .IR apples ,
617 the third number, the word
618 .I oranges
619 and then the second number.  You would fill in the Replace dialog box as
620 follows:
623 .B Enter search string
624 (%d,%d,%d)
625 .B Enter replace string
626 apples %d oranges %d
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
642 .B display bits
643 to 7 bits in the Midnight Commander options menu to keep the spacing
644 clean.
645 .SH FILES
646 .I %prefix%/share/mc/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 the 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.
665 .I ~/.config/mc/ini
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.
674 .SH LICENSE
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 the Midnight Commander for details on the License and the lack
678 of warranty.
679 .SH AVAILABILITY
680 The latest version of this program can be found at
681 http://ftp.midnight\-commander.org/.
682 .SH SEE ALSO
683 cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
684 .SH AUTHORS
685 Paul Sheer (psheer@obsidian.co.za) is the original author of
686 the Midnight Commander's internal editor.
687 .SH BUGS
688 Bugs should be reported to http://www.midnight\-commander.org/.