mcedit.1.in 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. .TH MCEDIT 1 "September 2007" "MC Version 4.6.2-pre1" "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>:<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 ~/.mc/cedit/cooledit.clip ,
  80. .B Shift-Ins
  81. pastes from
  82. .BR ~/.mc/cedit/cooledit.clip ,
  83. .B Shift-Del
  84. cuts to
  85. .BR ~/.mc/cedit/cooledit.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 "Alt-Tab"
  96. or
  97. .BR "Escape Tab" )
  98. completes the word under the cursor using the words used earlier in the
  99. file.
  100. .PP
  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 ~/.mc/cedit/cooledit.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.
  120. .P
  121. .B F19
  122. will format C, C++, Java or HTML code when it is highlighted. An executable
  123. file called
  124. .B ~/.mc/cedit/edit.indent.rc
  125. will be created for you from the default template. Feel free to edit it
  126. if you need.
  127. .PP
  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 ~/.mc/cedit/edit.spell.rc .
  132. .PP
  133. If some keys don't work, you can use
  134. .B Learn Keys
  135. in the
  136. .B Options
  137. menu.
  138. .SH SYNTAX HIGHLIGHTING
  139. .B mcedit
  140. supports syntax highlighting. This means that keywords and contexts
  141. (like C comments, string constants, etc) are highlighted in different
  142. colors. The following section explains the format of the file
  143. .BR ~/.mc/cedit/Syntax .
  144. If this file is missing, system-wide
  145. .B @prefix@/share/mc/syntax/Syntax
  146. is used.
  147. The file
  148. .B ~/.mc/cedit/Syntax
  149. is rescanned on opening of a any new editor file. The file contains
  150. rules for highlighting, each of which is given on a separate line, and
  151. define which keywords will be highlighted to what color.
  152. .PP
  153. The file is divided into sections, each beginning with a line with the
  154. .B file
  155. command. The sections are normally put into separate files using the
  156. .B include
  157. command.
  158. .PP
  159. The
  160. .B file
  161. command has three arguments. The first argument is a regular expression
  162. that is applied to the file name to determine if the following section
  163. applies to the file. The second argument is the description of the file
  164. type. It is used in
  165. .BR cooledit ;
  166. future versions of
  167. .B mcedit
  168. may use it as well. The third optional argument is a regular expression
  169. to match the first line of text of the file. The rules in the following
  170. section apply if either the file name or the first line of text matches.
  171. .PP
  172. A section ends with the start of another section. Each section is
  173. divided into contexts, and each context contains rules. A context is a
  174. scope within the text that a particular set of rules belongs to. For
  175. instance, the text within a C style comment (i.e. between
  176. .B /*
  177. and
  178. .BR */ )
  179. has its own color. This is a context, although it has no further rules
  180. inside it because there is probably nothing that we want highlighted
  181. within a C comment.
  182. .PP
  183. A trivial C programming section might look like this:
  184. .PP
  185. .nf
  186. file .\\*\\\\.c C\\sProgram\\sFile (#include|/\\\\\\*)
  187. wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
  188. # default colors
  189. define comment brown
  190. context default
  191. keyword whole if yellow
  192. keyword whole else yellow
  193. keyword whole for yellow
  194. keyword whole while yellow
  195. keyword whole do yellow
  196. keyword whole switch yellow
  197. keyword whole case yellow
  198. keyword whole static yellow
  199. keyword whole extern yellow
  200. keyword { brightcyan
  201. keyword } brightcyan
  202. keyword '*' green
  203. # C comments
  204. context /\\* \\*/ comment
  205. # C preprocessor directives
  206. context linestart # \\n red
  207. keyword \\\\\\n brightred
  208. # C string constants
  209. context " " green
  210. keyword %d brightgreen
  211. keyword %s brightgreen
  212. keyword %c brightgreen
  213. keyword \\\\" brightgreen
  214. .fi
  215. .PP
  216. Each context starts with a line of the form:
  217. .PP
  218. .B context
  219. .RB [ exclusive ]
  220. .RB [ whole | wholeright | wholeleft ]
  221. .RB [ linestart ]
  222. .I delim
  223. .RB [ linestart ]
  224. .I delim
  225. .RI [ foreground ]
  226. .RI [ background ]
  227. .PP
  228. The first context is an exception. It must start with the command
  229. .PP
  230. .B context default
  231. .RI [ foreground ]
  232. .RI [ background ]
  233. .PP
  234. otherwise
  235. .B mcedit
  236. will report an error. The
  237. .B linestart
  238. option specifies that
  239. .I delim
  240. must start at the beginning of a line. The
  241. .B whole
  242. option tells that
  243. .I delim
  244. must be a whole word. To specify that a word must begin on the word
  245. boundary only on the left side, you can use the
  246. .B wholeleft
  247. option, and similarly a word that must end on the word boundary is specified by
  248. .BR wholeright .
  249. .PP
  250. The set of characters that constitute a whole word can be changed at any
  251. point in the file with the
  252. .B wholechars
  253. command. The left and right set of characters can be set separately
  254. with
  255. .PP
  256. .B wholechars
  257. .RB [ left | right ]
  258. .I characters
  259. .PP
  260. The
  261. .B exclusive
  262. option causes the text between the delimiters to be highlighted, but not
  263. the delimiters themselves.
  264. .PP
  265. Each rule is a line of the form:
  266. .PP
  267. .B keyword
  268. .RB [ whole | wholeright | wholeleft ]
  269. .RB [ linestart ]
  270. .I string foreground
  271. .RI [ background ]
  272. .PP
  273. Context or keyword strings are interpreted, so that you can include tabs
  274. and spaces with the sequences \\t and \\s. Newlines and backslashes are
  275. specified with \\n and \\\\ respectively. Since whitespace is used as a
  276. separator, it may not be used as is. Also, \\* must be used to specify
  277. an asterisk. The * itself is a wildcard that matches any length of
  278. characters. For example,
  279. .PP
  280. .nf
  281. keyword '*' green
  282. .fi
  283. .PP
  284. colors all C single character constants green. You also could use
  285. .PP
  286. .nf
  287. keyword "*" green
  288. .fi
  289. .PP
  290. to color string constants, but the matched string would not be allowed
  291. to span across multiple newlines. The wildcard may be used within
  292. context delimiters as well, but you cannot have a wildcard as the last
  293. or first character.
  294. .PP
  295. Important to note is the line
  296. .PP
  297. .nf
  298. keyword \\\\\\n brightgreen
  299. .fi
  300. .PP
  301. This line defines a keyword containing the backslash and newline
  302. characters. Since the keywords are matched before the context
  303. delimiters, this keyword prevents the context from ending at the end of
  304. the lines that end in a backslash, thus allowing C preprocessor
  305. directive to continue across multiple lines.
  306. .PP
  307. The possible colors are: black, gray, red, brightred, green,
  308. brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta,
  309. cyan, brightcyan, lightgray and white. If the syntax file is shared
  310. with
  311. .BR cooledit ,
  312. it is possible to specify different colors for
  313. .B mcedit
  314. and
  315. .B cooledit
  316. by separating them with a slash, e.g.
  317. .PP
  318. .nf
  319. keyword #include red/Orange
  320. .fi
  321. .PP
  322. .B mcedit
  323. uses the color before the slash. See cooledit(1) for supported
  324. .B cooledit
  325. colors.
  326. .PP
  327. Comments may be put on a separate line starting with the hash sign (#).
  328. .PP
  329. Because of the simplicity of the implementation, there are a few
  330. intricacies that will not be dealt with correctly but these are a minor
  331. irritation. On the whole, a broad spectrum of quite complicated
  332. situations are handled with these simple rules. It is a good idea to
  333. take a look at the syntax file to see some of the nifty tricks you can
  334. do with a little imagination. If you cannot get by with the rules I
  335. have coded, and you think you have a rule that would be useful, please
  336. email me with your request. However, do not ask for regular expression
  337. support, because this is flatly impossible.
  338. .PP
  339. A useful hint is to work with as much as possible with the things you
  340. can do rather than try to do things that this implementation cannot deal
  341. with. Also remember that the aim of syntax highlighting is to make
  342. programming less prone to error, not to make code look pretty.
  343. .SH COLORS
  344. The default colors may be changed by appending to the
  345. .B MC_COLOR_TABLE
  346. environment variable. Foreground and background colors pairs may be
  347. specified for example with:
  348. .PP
  349. .nf
  350. MC_COLOR_TABLE="$MC_COLOR_TABLE:\\
  351. editnormal=lightgray,black:\\
  352. editbold=yellow,black:\\
  353. editmarked=black,cyan"
  354. .fi
  355. .SH OPTIONS
  356. Most options can now be set from the editors options dialog box. See
  357. the
  358. .B Options
  359. menu. The following options are defined in
  360. .B ~/.mc/ini
  361. and have obvious counterparts in the dialog box. You can modify them to
  362. change the editor behavior, by editing the file. Unless specified, a 1
  363. sets the option to on, and a 0 sets it to off, as is usual.
  364. .TP
  365. .I use_internal_edit
  366. This option is ignored when invoking
  367. .BR mcedit .
  368. .TP
  369. .I editor_key_emulation
  370. 1 for
  371. .B Emacs
  372. keys, and 0 for normal
  373. .B Cooledit
  374. keys.
  375. .TP
  376. .I editor_tab_spacing
  377. Interpret the tab character as being of this length.
  378. Default is 8. You should avoid using
  379. other than 8 since most other editors and text viewers
  380. assume a tab spacing of 8. Use
  381. .B editor_fake_half_tabs
  382. to simulate a smaller tab spacing.
  383. .TP
  384. .I editor_fill_tabs_with_spaces
  385. Never insert a tab space. Rather insert spaces (ascii 20h) to fill to the
  386. desired tab size.
  387. .TP
  388. .I editor_return_does_auto_indent
  389. Pressing return will tab across to match the indentation
  390. of the first line above that has text on it.
  391. .TP
  392. .I editor_backspace_through_tabs
  393. Make a single backspace delete all the space to the left
  394. margin if there is no text between the cursor and the left
  395. margin.
  396. .TP
  397. .I editor_fake_half_tabs
  398. This will emulate a half tab for those who want to program
  399. with a tab spacing of 4, but do not want the tab size changed
  400. from 8 (so that the code will be formatted the same when displayed
  401. by other programs). When editing between text and the left
  402. margin, moving and tabbing will be as though a tab space were
  403. 4, while actually using spaces and normal tabs for an optimal fill.
  404. When editing anywhere else, a normal tab is inserted.
  405. .TP
  406. .I editor_option_save_mode
  407. Possible values 0, 1 and 2. The save mode (see the options menu also)
  408. allows you to change the method of saving a file. Quick save (0) saves
  409. the file by immediately, truncating the disk file to zero length (i.e.
  410. erasing it) and the writing the editor contents to the file. This
  411. method is fast, but dangerous, since a system error during a file save
  412. will leave the file only partially written, possibly rendering the data
  413. irretrievable. When saving, the safe save (1) option enables creation
  414. of a temporary file into which the file contents are first written. In
  415. the event of an problem, the original file is untouched. When the
  416. temporary file is successfully written, it is renamed to the name of the
  417. original file, thus replacing it. The safest method is create backups
  418. (2). Where a backup file is created before any changes are made. You
  419. can specify your own backup file extension in the dialog. Note that
  420. saving twice will replace your backup as well as your original file.
  421. .SH MISCELLANEOUS
  422. You can use scanf search and replace to search and replace a C format
  423. string. First take a look at the
  424. .B sscanf
  425. and
  426. .B sprintf
  427. man pages to see what a format string is and how it works. Here's an
  428. example: suppose that you want to replace all occurrences of an open
  429. bracket, three comma separated numbers, and a close bracket, with the
  430. word
  431. .IR apples ,
  432. the third number, the word
  433. .I oranges
  434. and then the second number. You would fill in the Replace dialog box as
  435. follows:
  436. .PP
  437. .nf
  438. .B Enter search string
  439. (%d,%d,%d)
  440. .B Enter replace string
  441. apples %d oranges %d
  442. .B Enter replacement argument order
  443. 3,2
  444. .fi
  445. .PP
  446. The last line specifies that the third and then the second number are to
  447. be used in place of the first and second.
  448. .PP
  449. It is advisable to use this feature with Prompt On Replace on, because a
  450. match is thought to be found whenever the number of arguments found
  451. matches the number given, which is not always a real match. Scanf also
  452. treats whitespace as being elastic. Note that the scanf format %[ is
  453. very useful for scanning strings, and whitespace.
  454. .PP
  455. The editor also displays non-us characters (160+). When editing
  456. binary files, you should set
  457. .B display bits
  458. to 7 bits in the Midnight Commander options menu to keep the spacing
  459. clean.
  460. .SH FILES
  461. .I @prefix@/share/mc/mc.hlp
  462. .IP
  463. The help file for the program.
  464. .PP
  465. .I @prefix@/share/mc/mc.ini
  466. .IP
  467. The default system-wide setup for GNU Midnight Commander, used only if
  468. the user's own ~/.mc/ini file is missing.
  469. .PP
  470. .I @prefix@/share/mc/mc.lib
  471. .IP
  472. Global settings for the Midnight Commander. Settings in this file
  473. affect all users, whether they have ~/.mc/ini or not.
  474. .PP
  475. .I @prefix@/share/mc/syntax/*
  476. .IP
  477. The default system-wide syntax files for mcedit, used only if
  478. the corresponding user's own ~/.mc/cedit/ file is missing.
  479. .PP
  480. .I $HOME/.mc/ini
  481. .IP
  482. User's own setup. If this file is present then the setup is loaded
  483. from here instead of the system-wide setup file.
  484. .PP
  485. .I $HOME/.mc/cedit/
  486. .IP
  487. User's own directory where block commands are processed and saved and
  488. user's own syntax files are located.
  489. .SH LICENSE
  490. This program is distributed under the terms of the GNU General Public
  491. License as published by the Free Software Foundation. See the built-in
  492. help of the Midnight Commander for details on the License and the lack
  493. of warranty.
  494. .SH AVAILABILITY
  495. The latest version of this program can be found at
  496. ftp://ftp.gnu.org/gnu/mc/.
  497. .SH SEE ALSO
  498. cooledit(1), mc(1), gpm(1), terminfo(1), scanf(3).
  499. .SH AUTHORS
  500. Paul Sheer (psheer@obsidian.co.za) is the original author of
  501. the Midnight Commander's internal editor.
  502. .SH BUGS
  503. Bugs should be reported to mc-devel@gnome.org