1MCEDIT(1) GNU Midnight Commander MCEDIT(1)
2
3
4
6 mcedit - Internal file editor of GNU Midnight Commander.
7
9 mcedit [-bcCdfhstVx?] [+number] file
10
12 mcedit is a link to mc, the main GNU Midnight Commander executable.
13 Executing GNU Midnight Commander under this name requests staring the
14 internal editor and opening the file specified on the command line.
15 The editor is based on the terminal version of cooledit - standalone
16 editor for X Window System.
17
19 +number
20 Go to the line specified by number (do not put a space between
21 the + sign and the number).
22
23 -b Force black and white display.
24
25 -c Force ANSI color mode on terminals that don't seem to have color
26 support.
27
28 -C <keyword>=<FGcolor>,<BGcolor>:<keyword>= ...
29 Specify a different color set. See the Colors section in mc(1)
30 for more information.
31
32 -d Disable mouse support.
33
34 -f Display the compiled-in search path for GNU Midnight Commander
35 data files.
36
37 -t Force using termcap database instead of terminfo. This option
38 is only applicable if GNU Midnight Commander was compiled with
39 S-Lang library with terminfo support.
40
41 -V Display the version of the program.
42
43 -x Force xterm mode. Used when running on xterm-capable terminals
44 (two screen modes, and able to send mouse escape sequences).
45
47 The internal file editor is a full-featured full screen editor. It can
48 edit files up to 64 megabytes. It is possible to edit binary files.
49 The features it presently supports are: block copy, move, delete, cut,
50 paste; key for key undo; pull-down menus; file insertion; macro com‐
51 mands; regular expression search and replace (and our own scanf-printf
52 search and replace); shift-arrow text highlighting (if supported by the
53 terminal); insert-overwrite toggle; word wrap; autoindent; tunable tab
54 size; syntax highlighting for various file types; and an option to pipe
55 text blocks through shell commands like indent and ispell.
56
58 The editor is easy to use and can be used without learning. The pull-
59 down menu is invoked by pressing F9. You can learn other keys from the
60 menu and from the button bar labels.
61
62 In addition to that, Shift combined with arrows does text highlighting
63 (if supported by the terminal): Ctrl-Ins copies to the file
64 ~/.mc/cedit/cooledit.clip, Shift-Ins pastes from
65 ~/.mc/cedit/cooledit.clip, Shift-Del cuts to ~/.mc/cedit/cooledit.clip,
66 and Ctrl-Del deletes highlighted text. Mouse highlighting also works
67 on some terminals. To use the standard mouse support provided by your
68 terminal, hold the Shift key. Please note that the mouse support in
69 the terminal doesn't share the clipboard with mcedit.
70
71 The completion key (usually Alt-Tab or Escape Tab) completes the word
72 under the cursor using the words used earlier in the file.
73
74 To define a macro, press Ctrl-R and then type out the keys you want to
75 be executed. Press Ctrl-R again when finished. You can then assign
76 the macro to any key you like by pressing that key. The macro is exe‐
77 cuted when you press Ctrl-A and then the assigned key. The macro is
78 also executed if you press Meta, Ctrl, or Esc and the assigned key,
79 provided that the key is not used for any other function. The macro
80 commands are stored in the file ~/.mc/cedit/cooledit.macros. Do NOT
81 edit this file if you are going to use macros again in the same editing
82 session, because mcedit caches macro key defines in memory. mcedit now
83 overwrites a macro if a macro with the same key already exists, so you
84 won't have to edit this file. You will also have to restart other run‐
85 ning editors for macros to take effect.
86
87 F19 will format C, C++, Java or HTML code when it is highlighted. An
88 executable file called ~/.mc/cedit/edit.indent.rc will be created for
89 you from the default template. Feel free to edit it if you need.
90
91 C-p will run ispell on a block of text in a similar way. The script
92 file will be called ~/.mc/cedit/edit.spell.rc.
93
94 If some keys don't work, you can use Learn Keys in the Options menu.
95
97 mcedit supports syntax highlighting. This means that keywords and con‐
98 texts (like C comments, string constants, etc) are highlighted in dif‐
99 ferent colors. The following section explains the format of the file
100 ~/.mc/cedit/Syntax. If this file is missing, system-wide
101 /usr/share/mc/syntax/Syntax is used. The file ~/.mc/cedit/Syntax is
102 rescanned on opening of a any new editor file. The file contains rules
103 for highlighting, each of which is given on a separate line, and define
104 which keywords will be highlighted to what color.
105
106 The file is divided into sections, each beginning with a line with the
107 file command. The sections are normally put into separate files using
108 the include command.
109
110 The file command has three arguments. The first argument is a regular
111 expression that is applied to the file name to determine if the follow‐
112 ing section applies to the file. The second argument is the descrip‐
113 tion of the file type. It is used in cooledit; future versions of
114 mcedit may use it as well. The third optional argument is a regular
115 expression to match the first line of text of the file. The rules in
116 the following section apply if either the file name or the first line
117 of text matches.
118
119 A section ends with the start of another section. Each section is
120 divided into contexts, and each context contains rules. A context is a
121 scope within the text that a particular set of rules belongs to. For
122 instance, the text within a C style comment (i.e. between /* and */)
123 has its own color. This is a context, although it has no further rules
124 inside it because there is probably nothing that we want highlighted
125 within a C comment.
126
127 A trivial C programming section might look like this:
128
129 file .\*\\.c C\sProgram\sFile (#include|/\\\*)
130
131 wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
132
133 # default colors
134 define comment brown
135 context default
136 keyword whole if yellow
137 keyword whole else yellow
138 keyword whole for yellow
139 keyword whole while yellow
140 keyword whole do yellow
141 keyword whole switch yellow
142 keyword whole case yellow
143 keyword whole static yellow
144 keyword whole extern yellow
145 keyword { brightcyan
146 keyword } brightcyan
147 keyword '*' green
148
149 # C comments
150 context /\* \*/ comment
151
152 # C preprocessor directives
153 context linestart # \n red
154 keyword \\\n brightred
155
156 # C string constants
157 context " " green
158 keyword %d brightgreen
159 keyword %s brightgreen
160 keyword %c brightgreen
161 keyword \\" brightgreen
162
163 Each context starts with a line of the form:
164
165 context [exclusive] [whole|wholeright|wholeleft] [linestart] delim
166 [linestart] delim [foreground] [background]
167
168 The first context is an exception. It must start with the command
169
170 context default [foreground] [background]
171
172 otherwise mcedit will report an error. The linestart option specifies
173 that delim must start at the beginning of a line. The whole option
174 tells that delim must be a whole word. To specify that a word must
175 begin on the word boundary only on the left side, you can use the
176 wholeleft option, and similarly a word that must end on the word bound‐
177 ary is specified by wholeright.
178
179 The set of characters that constitute a whole word can be changed at
180 any point in the file with the wholechars command. The left and right
181 set of characters can be set separately with
182
183 wholechars [left|right] characters
184
185 The exclusive option causes the text between the delimiters to be high‐
186 lighted, but not the delimiters themselves.
187
188 Each rule is a line of the form:
189
190 keyword [whole|wholeright|wholeleft] [linestart] string foreground
191 [background]
192
193 Context or keyword strings are interpreted, so that you can include
194 tabs and spaces with the sequences \t and \s. Newlines and backslashes
195 are specified with \n and \\ respectively. Since whitespace is used as
196 a separator, it may not be used as is. Also, \* must be used to spec‐
197 ify an asterisk. The * itself is a wildcard that matches any length of
198 characters. For example,
199
200 keyword '*' green
201
202 colors all C single character constants green. You also could use
203
204 keyword "*" green
205
206 to color string constants, but the matched string would not be allowed
207 to span across multiple newlines. The wildcard may be used within con‐
208 text delimiters as well, but you cannot have a wildcard as the last or
209 first character.
210
211 Important to note is the line
212
213 keyword \\\n brightgreen
214
215 This line defines a keyword containing the backslash and newline char‐
216 acters. Since the keywords are matched before the context delimiters,
217 this keyword prevents the context from ending at the end of the lines
218 that end in a backslash, thus allowing C preprocessor directive to con‐
219 tinue across multiple lines.
220
221 The possible colors are: black, gray, red, brightred, green, bright‐
222 green, brown, yellow, blue, brightblue, magenta, brightmagenta, cyan,
223 brightcyan, lightgray and white. If the syntax file is shared with
224 cooledit, it is possible to specify different colors for mcedit and
225 cooledit by separating them with a slash, e.g.
226
227 keyword #include red/Orange
228
229 mcedit uses the color before the slash. See cooledit(1) for supported
230 cooledit colors.
231
232 Comments may be put on a separate line starting with the hash sign (#).
233
234 Because of the simplicity of the implementation, there are a few intri‐
235 cacies that will not be dealt with correctly but these are a minor
236 irritation. On the whole, a broad spectrum of quite complicated situa‐
237 tions are handled with these simple rules. It is a good idea to take a
238 look at the syntax file to see some of the nifty tricks you can do with
239 a little imagination. If you cannot get by with the rules I have
240 coded, and you think you have a rule that would be useful, please email
241 me with your request. However, do not ask for regular expression sup‐
242 port, because this is flatly impossible.
243
244 A useful hint is to work with as much as possible with the things you
245 can do rather than try to do things that this implementation cannot
246 deal with. Also remember that the aim of syntax highlighting is to
247 make programming less prone to error, not to make code look pretty.
248
250 The default colors may be changed by appending to the MC_COLOR_TABLE
251 environment variable. Foreground and background colors pairs may be
252 specified for example with:
253
254 MC_COLOR_TABLE="$MC_COLOR_TABLE:\
255 editnormal=lightgray,black:\
256 editbold=yellow,black:\
257 editmarked=black,cyan"
258
260 Most options can now be set from the editors options dialog box. See
261 the Options menu. The following options are defined in ~/.mc/ini and
262 have obvious counterparts in the dialog box. You can modify them to
263 change the editor behavior, by editing the file. Unless specified, a 1
264 sets the option to on, and a 0 sets it to off, as is usual.
265
266 use_internal_edit
267 This option is ignored when invoking mcedit.
268
269 editor_key_emulation
270 1 for Emacs keys, and 0 for normal Cooledit keys.
271
272 editor_tab_spacing
273 Interpret the tab character as being of this length. Default is
274 8. You should avoid using other than 8 since most other editors
275 and text viewers assume a tab spacing of 8. Use edi‐
276 tor_fake_half_tabs to simulate a smaller tab spacing.
277
278 editor_fill_tabs_with_spaces
279 Never insert a tab space. Rather insert spaces (ascii 20h) to
280 fill to the desired tab size.
281
282 editor_return_does_auto_indent
283 Pressing return will tab across to match the indentation of the
284 first line above that has text on it.
285
286 editor_backspace_through_tabs
287 Make a single backspace delete all the space to the left margin
288 if there is no text between the cursor and the left margin.
289
290 editor_fake_half_tabs
291 This will emulate a half tab for those who want to program with
292 a tab spacing of 4, but do not want the tab size changed from 8
293 (so that the code will be formatted the same when displayed by
294 other programs). When editing between text and the left margin,
295 moving and tabbing will be as though a tab space were 4, while
296 actually using spaces and normal tabs for an optimal fill. When
297 editing anywhere else, a normal tab is inserted.
298
299 editor_option_save_mode
300 Possible values 0, 1 and 2. The save mode (see the options menu
301 also) allows you to change the method of saving a file. Quick
302 save (0) saves the file by immediately, truncating the disk file
303 to zero length (i.e. erasing it) and the writing the editor
304 contents to the file. This method is fast, but dangerous, since
305 a system error during a file save will leave the file only par‐
306 tially written, possibly rendering the data irretrievable. When
307 saving, the safe save (1) option enables creation of a temporary
308 file into which the file contents are first written. In the
309 event of an problem, the original file is untouched. When the
310 temporary file is successfully written, it is renamed to the
311 name of the original file, thus replacing it. The safest method
312 is create backups (2). Where a backup file is created before
313 any changes are made. You can specify your own backup file
314 extension in the dialog. Note that saving twice will replace
315 your backup as well as your original file.
316
318 You can use scanf search and replace to search and replace a C format
319 string. First take a look at the sscanf and sprintf man pages to see
320 what a format string is and how it works. Here's an example: suppose
321 that you want to replace all occurrences of an open bracket, three
322 comma separated numbers, and a close bracket, with the word apples, the
323 third number, the word oranges and then the second number. You would
324 fill in the Replace dialog box as follows:
325
326 Enter search string
327 (%d,%d,%d)
328 Enter replace string
329 apples %d oranges %d
330 Enter replacement argument order
331 3,2
332
333 The last line specifies that the third and then the second number are
334 to be used in place of the first and second.
335
336 It is advisable to use this feature with Prompt On Replace on, because
337 a match is thought to be found whenever the number of arguments found
338 matches the number given, which is not always a real match. Scanf also
339 treats whitespace as being elastic. Note that the scanf format %[ is
340 very useful for scanning strings, and whitespace.
341
342 The editor also displays non-us characters (160+). When editing binary
343 files, you should set display bits to 7 bits in the Midnight Commander
344 options menu to keep the spacing clean.
345
347 /usr/share/mc/mc.hlp
348
349 The help file for the program.
350
351 /usr/share/mc/mc.ini
352
353 The default system-wide setup for GNU Midnight Commander, used
354 only if the user's own ~/.mc/ini file is missing.
355
356 /usr/share/mc/mc.lib
357
358 Global settings for the Midnight Commander. Settings in this
359 file affect all users, whether they have ~/.mc/ini or not.
360
361 /usr/share/mc/syntax/*
362
363 The default system-wide syntax files for mcedit, used only if
364 the corresponding user's own ~/.mc/cedit/ file is missing.
365
366 $HOME/.mc/ini
367
368 User's own setup. If this file is present then the setup is
369 loaded from here instead of the system-wide setup file.
370
371 $HOME/.mc/cedit/
372
373 User's own directory where block commands are processed and
374 saved and user's own syntax files are located.
375
377 This program is distributed under the terms of the GNU General Public
378 License as published by the Free Software Foundation. See the built-in
379 help of the Midnight Commander for details on the License and the lack
380 of warranty.
381
383 The latest version of this program can be found at ftp://ftp.ibib‐
384 lio.org/pub/Linux/utils/file/managers/mc/.
385
387 cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
388
390 Paul Sheer (psheer@obsidian.co.za) is the original author of the Mid‐
391 night Commander's internal editor.
392
394 Bugs should be reported to mc-devel@gnome.org
395
396
397
398MC Version 4.6.0 January 2003 MCEDIT(1)