Merge branch '2509_diff_quick_move'
[pantumic.git] / doc / man / mcedit.1.in
blob62a991217d2d8019541df15dd5aec9b9e4d5805a
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.
101 To define a macro, press
102 .B Ctrl\-R
103 and then type out the keys you want to be executed.  Press
104 .B Ctrl\-R
105 again when finished.  You can then assign the macro to any key you like
106 by pressing that key.  The macro is executed when you press
107 .B Ctrl\-A
108 and then the assigned key.  The macro is also executed if you press
109 Meta, Ctrl, or Esc and the assigned key, provided that the key is not
110 used for any other function.  The macro commands are stored in the file
111 .BR ~/.local/share/mc/mcedit/mcedit.macros .
112 Do NOT edit this file if you are going to use macros again in the same
113 editing session, because
114 .B mcedit
115 caches macro key defines in memory.
116 .B mcedit
117 now overwrites a macro if a macro with the same key already exists,
118 so you won't have to edit this file. You will also have to restart
119 other running editors for macros to take effect.
121 .B F19
122 will format C, C++, Java or HTML code when it is highlighted.  An executable
123 file called
124 .B ~/.local/share/mc/mcedit/edit.indent.rc
125 will be created for you from the default template.  Feel free to edit it
126 if you need.
128 .B C\-p
129 will run ispell on a block of text in a similar way.  The script file
130 will be called
131 .BR ~/.local/share/mc/mcedit/edit.spell.rc .
133 If some keys don't work, you can use
134 .B Learn Keys
135 in the
136 .B Options
137 menu.
138 .SH CODE NAVIGATION
139 .B mcedit
140 can be used to navigation through code with tags files created by etags
141 or ctags commands. If there is no file TAGS code navigation would not work.
142 In example, in case of exuberant\-ctags for C language command will be:
144 ctags \-e \-\-language\-force=C \-R ./
146 .B Meta\-Enter 
147 show list box to select item under cursor (cusor should stand at end of
148 word).
150 .B Meta\-Minus 
151 where minus is symbol "\-" go to previous function in navigation list (like a browser
152 Back).
154 .B Meta\-Equal
155 where equal is symbol "=" go to next function in navigation list (like a browser
156 Forward).
158 .SH SYNTAX HIGHLIGHTING
159 .B mcedit
160 supports syntax highlighting.  This means that keywords and contexts
161 (like C comments, string constants, etc) are highlighted in different
162 colors.  The following section explains the format of the file
163 .BR ~/.local/share/mc/mcedit/Syntax .
164 If this file is missing, system\-wide
165 .B @prefix@/share/mc/syntax/Syntax
166 is used.
167 The file
168 .B ~/.local/share/mc/mcedit/Syntax
169 is rescanned on opening of a any new editor file.  The file contains
170 rules for highlighting, each of which is given on a separate line, and
171 define which keywords will be highlighted to what color.
173 The file is divided into sections, each beginning with a line with the
174 .B file
175 command.  The sections are normally put into separate files using the
176 .B include
177 command.
180 .B file
181 command has three arguments.  The first argument is a regular expression
182 that is applied to the file name to determine if the following section
183 applies to the file.  The second argument is the description of the file
184 type.  It is used in
185 .BR cooledit ;
186 future versions of
187 .B mcedit
188 may use it as well.  The third optional argument is a regular expression
189 to match the first line of text of the file.  The rules in the following
190 section apply if either the file name or the first line of text matches.
192 A section ends with the start of another section.  Each section is
193 divided into contexts, and each context contains rules.  A context is a
194 scope within the text that a particular set of rules belongs to.  For
195 instance, the text within a C style comment (i.e. between
196 .B /*
198 .BR */ )
199 has its own color.  This is a context, although it has no further rules
200 inside it because there is probably nothing that we want highlighted
201 within a C comment.
203 A trivial C programming section might look like this:
206 file .\\*\\\\.c C\\sProgram\\sFile (#include|/\\\\\\*)
208 wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
210 # default colors
211 define  comment   brown
212 context default
213   keyword  whole  if       yellow
214   keyword  whole  else     yellow
215   keyword  whole  for      yellow
216   keyword  whole  while    yellow
217   keyword  whole  do       yellow
218   keyword  whole  switch   yellow
219   keyword  whole  case     yellow
220   keyword  whole  static   yellow
221   keyword  whole  extern   yellow
222   keyword         {        brightcyan
223   keyword         }        brightcyan
224   keyword         '*'      green
226 # C comments
227 context /\\* \\*/ comment
229 # C preprocessor directives
230 context linestart # \\n red
231   keyword  \\\\\\n  brightred
233 # C string constants
234 context " " green
235   keyword  %d    brightgreen
236   keyword  %s    brightgreen
237   keyword  %c    brightgreen
238   keyword  \\\\"   brightgreen
241 Each context starts with a line of the form:
243 .B context
244 .RB [ exclusive ]
245 .RB [ whole | wholeright | wholeleft ]
246 .RB [ linestart ]
247 .I delim
248 .RB [ linestart ]
249 .I delim
250 .RI [ foreground ]
251 .RI [ background ]
252 .RI [ attributes ]
254 The first context is an exception.  It must start with the command
256 .B context default
257 .RI [ foreground ]
258 .RI [ background ]
259 .RI [ attributes ]
261 otherwise
262 .B mcedit
263 will report an error.  The
264 .B linestart
265 option specifies that
266 .I delim
267 must start at the beginning of a line.  The
268 .B whole
269 option tells that
270 .I delim
271 must be a whole word.  To specify that a word must begin on the word
272 boundary only on the left side, you can use the
273 .B wholeleft
274 option, and similarly a word that must end on the word boundary is specified by
275 .BR wholeright .
277 The set of characters that constitute a whole word can be changed at any
278 point in the file with the
279 .B wholechars
280 command.  The left and right set of characters can be set separately
281 with
283 .B wholechars
284 .RB [ left | right ]
285 .I characters
288 .B exclusive
289 option causes the text between the delimiters to be highlighted, but not
290 the delimiters themselves.
292 Each rule is a line of the form:
294 .B keyword
295 .RB [ whole | wholeright | wholeleft ]
296 .RB [ linestart ]
297 .I string foreground
298 .RI [ background ]
299 .RI [ attributes ]
301 Context or keyword strings are interpreted, so that you can include tabs
302 and spaces with the sequences \\t and \\s.  Newlines and backslashes are
303 specified with \\n and \\\\ respectively.  Since whitespace is used as a
304 separator, it may not be used as is.  Also, \\* must be used to specify
305 an asterisk.  The * itself is a wildcard that matches any length of
306 characters.  For example,
309   keyword         '*'      green
312 colors all C single character constants green.  You also could use
315   keyword         "*"      green
318 to color string constants, but the matched string would not be allowed
319 to span across multiple newlines.  The wildcard may be used within
320 context delimiters as well, but you cannot have a wildcard as the last
321 or first character.
323 Important to note is the line
326   keyword  \\\\\\n  brightgreen
329 This line defines a keyword containing the backslash and newline
330 characters.  Since the keywords are matched before the context
331 delimiters, this keyword prevents the context from ending at the end of
332 the lines that end in a backslash, thus allowing C preprocessor
333 directive to continue across multiple lines.
335 The possible colors are: black, gray, red, brightred, green,
336 brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta,
337 cyan, brightcyan, lightgray and white. The special keyword "default" means
338 the terminal's default. Another special keyword "base" means mc's main
339 colors, it is useful as a placeholder if you want to specify attributes
340 without modifying the background color. When 256 colors are available,
341 they can be specified either as color16 to color255, or as rgb000 to rgb555
342 and gray0 to gray23.
344 If the syntax file is shared with
345 .BR cooledit ,
346 it is possible to specify different colors for
347 .B mcedit
349 .B cooledit
350 by separating them with a slash, e.g.
353 keyword  #include  red/Orange
356 .B mcedit
357 uses the color before the slash.  See cooledit(1) for supported
358 .B cooledit
359 colors.
361 Attributes can be any of bold, underline, reverse and blink, appended by a
362 plus sign if more than one are desired.
364 Comments may be put on a separate line starting with the hash sign (#).
366 If you are describing case insensitive language you need to use
367 .B caseinsensitive
368 derective. It should be specified at the begining of syntax file.
370 Because of the simplicity of the implementation, there are a few
371 intricacies that will not be dealt with correctly but these are a minor
372 irritation.  On the whole, a broad spectrum of quite complicated
373 situations are handled with these simple rules.  It is a good idea to
374 take a look at the syntax file to see some of the nifty tricks you can
375 do with a little imagination.  If you cannot get by with the rules I
376 have coded, and you think you have a rule that would be useful, please
377 email me with your request.  However, do not ask for regular expression
378 support, because this is flatly impossible.
380 A useful hint is to work with as much as possible with the things you
381 can do rather than try to do things that this implementation cannot deal
382 with.  Also remember that the aim of syntax highlighting is to make
383 programming less prone to error, not to make code look pretty.
385 The syntax highlighting can be toggled using Ctrl\-s shortcut.
386 .SH COLORS
387 The default colors may be changed by appending to the
388 .B MC_COLOR_TABLE
389 environment variable.  Foreground and background colors pairs may be
390 specified for example with:
393 MC_COLOR_TABLE="$MC_COLOR_TABLE:\\
394 editnormal=lightgray,black:\\
395 editbold=yellow,black:\\
396 editmarked=black,cyan"
398 .SH OPTIONS
399 Most options can now be set from the editors options dialog box.  See
401 .B Options
402 menu.  The following options are defined in
403 .B ~/.config/mc/ini
404 and have obvious counterparts in the dialog box.  You can modify them to
405 change the editor behavior, by editing the file.  Unless specified, a 1
406 sets the option to on, and a 0 sets it to off, as is usual.
408 .I use_internal_edit
409 This option is ignored when invoking
410 .BR mcedit .
412 .I editor_tab_spacing
413 Interpret the tab character as being of this length.
414 Default is 8. You should avoid using
415 other than 8 since most other editors and text viewers
416 assume a tab spacing of 8. Use
417 .B editor_fake_half_tabs
418 to simulate a smaller tab spacing.
420 .I editor_fill_tabs_with_spaces
421 Never insert a tab space. Rather insert spaces (ascii 20h) to fill to the
422 desired tab size.
424 .I editor_return_does_auto_indent
425 Pressing return will tab across to match the indentation
426 of the first line above that has text on it.
428 .I editor_backspace_through_tabs
429 Make a single backspace delete all the space to the left
430 margin if there is no text between the cursor and the left
431 margin.
433 .I editor_fake_half_tabs
434 This will emulate a half tab for those who want to program
435 with a tab spacing of 4, but do not want the tab size changed
436 from 8 (so that the code will be formatted the same when displayed
437 by other programs). When editing between text and the left
438 margin, moving and tabbing will be as though a tab space were
439 4, while actually using spaces and normal tabs for an optimal fill.
440 When editing anywhere else, a normal tab is inserted.
442 .I editor_option_save_mode
443 Possible values 0, 1 and 2.  The save mode (see the options menu also)
444 allows you to change the method of saving a file.  Quick save (0) saves
445 the file by immediately, truncating the disk file to zero length (i.e.
446 erasing it) and the writing the editor contents to the file.  This
447 method is fast, but dangerous, since a system error during a file save
448 will leave the file only partially written, possibly rendering the data
449 irretrievable.  When saving, the safe save (1) option enables creation
450 of a temporary file into which the file contents are first written.  In
451 the event of an problem, the original file is untouched.  When the
452 temporary file is successfully written, it is renamed to the name of the
453 original file, thus replacing it.  The safest method is create backups
454 (2).  Where a backup file is created before any changes are made.  You
455 can specify your own backup file extension in the dialog.  Note that
456 saving twice will replace your backup as well as your original file.
458 .I editor_word_wrap_line_length
459 line length to wrap. 72 default.
461 .I editor_backup_extension
462 symbol for add extension to name of backup files. Default "~".
464 .I editor_line_state
465 show state line of editor now it show number of file line (in future it
466 can show things like folding, breakpoints, etc.). M\-n toglle this option.
468 .I editor_visible_spaces
469 Toggle show visible trailing spaces (TWS), if editor_visible_spaces=1 TWS
470 showed as '.'
472 .I editor_visible_tabs
473 Toggle show visible tabs, if editor_visible_tabs=1 tabs showed as '<\-\-\-\->'
475 .I editor_persistent_selections
476 Do not remove block selection after moving the cursor.
478 .I editor_cursor_beyond_eol
479 Allow moving cursor beyond the end of line.
481 .I editor_syntax_highlighting
482 enable syntax highlighting.
484 .I editor_edit_confirm_save
485 show confirm dialog on save.
487 .I editor_option_typewriter_wrap
488 to be described
490 .I editor_option_auto_para_formatting
491 to be described
493 .I editor_option_save_position
494 save file position on exit.
496 .I source_codepage
497 symbol representation of codepage name for file (i.e. CP1251, ~ \- default).
499 .I editor_group_undo
500 do UNDO for several of the same type of action (inserting/overwriting,
501 deleting, navigating, typing)
503 .I editor_wordcompletion_collect_entire_file
504 Search autocomplete candidates in entire of file or just from
505 begin of file to cursor position (0)
507 .SH MISCELLANEOUS
508 You can use scanf search and replace to search and replace a C format
509 string.  First take a look at the
510 .B sscanf
512 .B sprintf
513 man pages to see what a format string is and how it works.  Here's an
514 example: suppose that you want to replace all occurrences of an open
515 bracket, three comma separated numbers, and a close bracket, with the
516 word
517 .IR apples ,
518 the third number, the word
519 .I oranges
520 and then the second number.  You would fill in the Replace dialog box as
521 follows:
524 .B Enter search string
525 (%d,%d,%d)
526 .B Enter replace string
527 apples %d oranges %d
528 .B Enter replacement argument order
532 The last line specifies that the third and then the second number are to
533 be used in place of the first and second.
535 It is advisable to use this feature with Prompt On Replace on, because a
536 match is thought to be found whenever the number of arguments found
537 matches the number given, which is not always a real match. Scanf also
538 treats whitespace as being elastic.  Note that the scanf format %[ is
539 very useful for scanning strings, and whitespace.
541 The editor also displays non\-us characters (160+).  When editing
542 binary files, you should set
543 .B display bits
544 to 7 bits in the Midnight Commander options menu to keep the spacing
545 clean.
546 .SH FILES
547 .I @prefix@/share/mc/mc.hlp
549 The help file for the program.
551 .I @prefix@/share/mc/mc.ini
553 The default system\-wide setup for GNU Midnight Commander, used only if
554 the user's own ~/.config/mc/ini file is missing.
556 .I @prefix@/share/mc/mc.lib
558 Global settings for the Midnight Commander.  Settings in this file
559 affect all users, whether they have ~/.config/mc/ini or not.
561 .I @prefix@/share/mc/syntax/*
563 The default system\-wide syntax files for mcedit, used only if
564 the corresponding user's own ~/.local/share/mc/mcedit/ file is missing.
566 .I ~/.config/mc/ini
568 User's own setup.  If this file is present then the setup is loaded
569 from here instead of the system\-wide setup file.
571 .I ~/.local/share/mc/mcedit/
573 User's own directory where block commands are processed and saved and
574 user's own syntax files are located.
575 .SH LICENSE
576 This program is distributed under the terms of the GNU General Public
577 License as published by the Free Software Foundation.  See the built\-in
578 help of the Midnight Commander for details on the License and the lack
579 of warranty.
580 .SH AVAILABILITY
581 The latest version of this program can be found at
582 http://midnight\-commander.org/.
583 .SH SEE ALSO
584 cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
585 .SH AUTHORS
586 Paul Sheer (psheer@obsidian.co.za) is the original author of
587 the Midnight Commander's internal editor.
588 .SH BUGS
589 Bugs should be reported to mc\-devel@gnome.org