Ticket #2692: Date not set properly in manpage
[midnight-commander.git] / doc / man / mcedit.1.in
bloba59c4f3bd60012d3be892bbbac0c98bce6a468bf
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] file
7 .PP
8 .B mcedit
9 [\-bcCdfhstVx?] file: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
15 Commander under this name requests staring the internal editor and
16 opening the
17 .I file
18 specified on the command line.  The editor is based on the terminal
19 version of
20 .B cooledit
21 \- standalone editor for X Window System.
22 .SH OPTIONS
23 .TP
24 .I "+lineno"
25 Go to the line specified by number (do not put a space between the
26 .I "+"
27 sign and the number).
28 .TP
29 .I "\-b"
30 Force black and white display.
31 .TP
32 .I "\-c"
33 Force ANSI color mode on terminals that don't seem to have color
34 support.
35 .TP
36 .I "\-C <keyword>=<fgcolor>,<bgcolor>,<attributes>:<keyword>= ..."
37 Specify a different color set.  See the
38 .B Colors
39 section in mc(1) for more information.
40 .TP
41 .I "\-d"
42 Disable mouse support.
43 .TP
44 .I "\-f"
45 Display the compiled\-in search path for GNU Midnight Commander data
46 files.
47 .TP
48 .I "\-t"
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.
52 .TP
53 .I "\-V"
54 Display the version of the program.
55 .TP
56 .I "\-x"
57 Force xterm mode.  Used when running on xterm\-capable terminals (two
58 screen modes, and able to send mouse escape sequences).
59 .SH FEATURES
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
69 indent and ispell.
70 .SH KEYS
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.
74 .PP
75 In addition to that, Shift combined with arrows does text highlighting
76 (if supported by the terminal):
77 .B Ctrl\-Ins
78 copies to the file
79 .BR ~/.cache/mc/mcedit/mcedit.clip ,
80 .B Shift\-Ins
81 pastes from
82 .BR ~/.cache/mc/mcedit/mcedit.clip ,
83 .B Shift\-Del
84 cuts to
85 .BR ~/.cache/mc/mcedit/mcedit.clip ,
86 and
87 .B Ctrl\-Del
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
92 .BR mcedit .
93 .PP
94 The completion key (usually
95 .B "Meta\-Tab"
97 .BR "Escape Tab" )
98 completes the word under the cursor using the words used earlier in the
99 file.
100 .SH MACRO
102 To define a macro, press
103 .B Ctrl\-R
104 and then type out the keys you want to be executed.  Press
105 .B Ctrl\-R
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
110 .B [editor]
111 it the file
112 .BR ~/.local/share/mc/mc.macros .
114 External scripts (filters) can be assigned into the any hotkey by edit
115 .B mc.macros
116 like following:
119 [editor]
120 ctrl\-W=ExecuteScript:25;
123 This means that ctrl\-W hotkey initiates the
124 .I ExecuteScript(25)
125 action, then editor handler translates this into execution of
126 .B ~/.local/share/mc/mcedit/macros.d/macro.25.sh
127 shell script.
129 External scripts are stored in
130 .B ~/.local/share/mc/mcedit/macros.d/
131 directory and must be named as
132 .B macro.XXXX.sh
133 where
134 .B XXXX
135 is the number from 0 to 9999.
137 .B Menu File Edit
138 for more detail about format of the script.
140 Following macro definition and directives can be used:
142 .I #silent
143 If this directive is set, then script starts without interactive subshell.
145 .I %c
146 The cursor column position number.
148 .I %i
149 The indent of blank space, equal the cursor column.
151 .I %y
152 The syntax type of current file.
154 .I %b
155 The block file name.
157 .I %f
158 The current file name.
160 .I %n
161 Only the current file name without extension.
163 .I %x
164 The extension of current file name.
166 .I %d
167 The current directory name.
169 .I %F
170 The current file in the unselected panel.
172 .I %D
173 The directory name of the unselected panel.
175 .I %t
176 The currently tagged files.
178 .I %T
179 The tagged files in the unselected panel.
181 .I %u
183 .I %U
184 Similar to the
185 .I %t
187 .I %T
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.
192 .I %s
194 .I %S
195 The selected files: The tagged files if there are any. Otherwise the
196 current file.
198 Feel free to edit this files, if you need.
199 Here is a sample external script:
202 l       comment selection
203         TMPFILE=`mktemp ${MC_TMPDIR:\-/tmp}/up.XXXXXX` || exit 1
204         echo #if 0 > $TMPFILE
205         cat %b >> $TMPFILE
206         echo #endif >> $TMPFILE
207         cat $TMPFILE > %b
208         rm \-f $TMPFILE
211 If some keys don't work, you can use
212 .B Learn Keys
213 in the
214 .B Options
215 menu.
216 .SH CODE NAVIGATION
217 .B mcedit
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 ./
224 .B Meta\-Enter 
225 show list box to select item under cursor (cusor should stand at end of
226 word).
228 .B Meta\-Minus 
229 where minus is symbol "\-" go to previous function in navigation list (like a browser
230 Back).
232 .B Meta\-Equal
233 where equal is symbol "=" go to next function in navigation list (like a browser
234 Forward).
236 .SH SYNTAX HIGHLIGHTING
237 .B mcedit
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 ~/.config/mc/mcedit/Syntax .
242 If this file is missing, system\-wide
243 .B %prefix%/share/mc/syntax/Syntax
244 is used.
245 The file
246 .B ~/.config/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
252 .B file
253 command.  The sections are normally put into separate files using the
254 .B include
255 command.
258 .B file
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
262 type.  It is used in
263 .BR cooledit ;
264 future versions of
265 .B mcedit
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
274 .B /*
276 .BR */ )
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
279 within a C comment.
281 A trivial C programming section might look like this:
284 file .\\*\\\\.c C\\sProgram\\sFile (#include|/\\\\\\*)
286 wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
288 # default colors
289 define  comment   brown
290 context default
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
300   keyword         {        brightcyan
301   keyword         }        brightcyan
302   keyword         '*'      green
304 # C comments
305 context /\\* \\*/ comment
307 # C preprocessor directives
308 context linestart # \\n red
309   keyword  \\\\\\n  brightred
311 # C string constants
312 context " " green
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:
321 .B context
322 .RB [ exclusive ]
323 .RB [ whole | wholeright | wholeleft ]
324 .RB [ linestart ]
325 .I delim
326 .RB [ linestart ]
327 .I delim
328 .RI [ foreground ]
329 .RI [ background ]
330 .RI [ attributes ]
332 The first context is an exception.  It must start with the command
334 .B context default
335 .RI [ foreground ]
336 .RI [ background ]
337 .RI [ attributes ]
339 otherwise
340 .B mcedit
341 will report an error.  The
342 .B linestart
343 option specifies that
344 .I delim
345 must start at the beginning of a line.  The
346 .B whole
347 option tells that
348 .I delim
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
351 .B wholeleft
352 option, and similarly a word that must end on the word boundary is specified by
353 .BR wholeright .
355 The set of characters that constitute a whole word can be changed at any
356 point in the file with the
357 .B wholechars
358 command.  The left and right set of characters can be set separately
359 with
361 .B wholechars
362 .RB [ left | right ]
363 .I characters
366 .B exclusive
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:
372 .B keyword
373 .RB [ whole | wholeright | wholeleft ]
374 .RB [ linestart ]
375 .I string foreground
376 .RI [ background ]
377 .RI [ attributes ]
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,
387   keyword         '*'      green
390 colors all C single character constants green.  You also could use
393   keyword         "*"      green
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
399 or first character.
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
420 and gray0 to gray23.
422 If the syntax file is shared with
423 .BR cooledit ,
424 it is possible to specify different colors for
425 .B mcedit
427 .B cooledit
428 by separating them with a slash, e.g.
431 keyword  #include  red/Orange
434 .B mcedit
435 uses the color before the slash.  See cooledit(1) for supported
436 .B cooledit
437 colors.
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
445 .B caseinsensitive
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.
464 .SH COLORS
465 The default colors may be changed by appending to the
466 .B MC_COLOR_TABLE
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"
476 .SH OPTIONS
477 Most options can now be set from the editors options dialog box.  See
479 .B Options
480 menu.  The following options are defined in
481 .B ~/.config/mc/ini
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.
486 .I use_internal_edit
487 This option is ignored when invoking
488 .BR mcedit .
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
500 desired tab size.
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
509 margin.
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 "~".
542 .I editor_line_state
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
548 showed as '.'
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
566 to be described
568 .I editor_option_auto_para_formatting
569 to be described
571 .I editor_option_save_position
572 save file position on exit.
574 .I source_codepage
575 symbol representation of codepage name for file (i.e. CP1251, ~ \- default).
577 .I editor_group_undo
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)
585 .SH MISCELLANEOUS
586 You can use scanf search and replace to search and replace a C format
587 string.  First take a look at the
588 .B sscanf
590 .B sprintf
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
594 word
595 .IR apples ,
596 the third number, the word
597 .I oranges
598 and then the second number.  You would fill in the Replace dialog box as
599 follows:
602 .B Enter search string
603 (%d,%d,%d)
604 .B Enter replace string
605 apples %d oranges %d
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
621 .B display bits
622 to 7 bits in the Midnight Commander options menu to keep the spacing
623 clean.
624 .SH FILES
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.
644 .I ~/.config/mc/ini
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.
653 .SH LICENSE
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
657 of warranty.
658 .SH AVAILABILITY
659 The latest version of this program can be found at
660 http://midnight\-commander.org/.
661 .SH SEE ALSO
662 cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
663 .SH AUTHORS
664 Paul Sheer (psheer@obsidian.co.za) is the original author of
665 the Midnight Commander's internal editor.
666 .SH BUGS
667 Bugs should be reported to mc\-devel@gnome.org