Mcedit linux что это
mcedit is a link to mc , the main GNU Midnight Commander executable. Executing GNU Midnight Commander under this name requests staring the internal editor and opening the file specified on the command line. The editor is based on the terminal version of cooledit — standalone editor for X Window System.
OPTIONS
FEATURES
In addition to that, Shift combined with arrows does text highlighting (if supported by the terminal): Ctrl-Ins copies to the file
/.mc/cedit/cooledit.clip , Shift-Ins pastes from
/.mc/cedit/cooledit.clip , Shift-Del cuts to
/.mc/cedit/cooledit.clip , and Ctrl-Del deletes highlighted text. Mouse highlighting also works on some terminals. To use the standard mouse support provided by your terminal, hold the Shift key. Please note that the mouse support in the terminal doesn’t share the clipboard with mcedit .
The completion key (usually Alt-Tab or Escape Tab ) completes the word under the cursor using the words used earlier in the file.
To define a macro, press Ctrl-R and then type out the keys you want to be executed. Press Ctrl-R again when finished. You can then assign the macro to any key you like by pressing that key. The macro is executed when you press Ctrl-A and then the assigned key. The macro is also executed if you press Meta, Ctrl, or Esc and the assigned key, provided that the key is not used for any other function. The macro commands are stored in the file
/.mc/cedit/cooledit.macros . Do NOT edit this file if you are going to use macros again in the same editing session, because mcedit caches macro key defines in memory. mcedit now overwrites a macro if a macro with the same key already exists, so you won’t have to edit this file. You will also have to restart other running editors for macros to take effect. F19 will format C, C++, Java or HTML code when it is highlighted. An executable file called
/.mc/cedit/edit.indent.rc will be created for you from the default template. Feel free to edit it if you need.
C-p will run ispell on a block of text in a similar way. The script file will be called
If some keys don’t work, you can use Learn Keys in the Options menu.
SYNTAX HIGHLIGHTING
/.mc/cedit/Syntax . If this file is missing, system-wide /usr/share/mc/syntax/Syntax is used. The file
/.mc/cedit/Syntax is rescanned on opening of a any new editor file. The file contains rules for highlighting, each of which is given on a separate line, and define which keywords will be highlighted to what color.
The file is divided into sections, each beginning with a line with the file command. The sections are normally put into separate files using the include command.
The file command has three arguments. The first argument is a regular expression that is applied to the file name to determine if the following section applies to the file. The second argument is the description of the file type. It is used in cooledit ; future versions of mcedit may use it as well. The third optional argument is a regular expression to match the first line of text of the file. The rules in the following section apply if either the file name or the first line of text matches.
A section ends with the start of another section. Each section is divided into contexts, and each context contains rules. A context is a scope within the text that a particular set of rules belongs to. For instance, the text within a C style comment (i.e. between /* and */ ) has its own color. This is a context, although it has no further rules inside it because there is probably nothing that we want highlighted within a C comment.
A trivial C programming section might look like this:
Each context starts with a line of the form:
context [ exclusive ] [ whole | wholeright | wholeleft ] [ linestart ] delim [ linestart ] delim [ foreground ] [ background ]
The first context is an exception. It must start with the command
context default [ foreground ] [ background ]
otherwise mcedit will report an error. The linestart option specifies that delim must start at the beginning of a line. The whole option tells that delim must be a whole word. To specify that a word must begin on the word boundary only on the left side, you can use the wholeleft option, and similarly a word that must end on the word boundary is specified by wholeright .
The set of characters that constitute a whole word can be changed at any point in the file with the wholechars command. The left and right set of characters can be set separately with
wholechars [ left | right ] characters
The exclusive option causes the text between the delimiters to be highlighted, but not the delimiters themselves.
Each rule is a line of the form:
keyword [ whole | wholeright | wholeleft ] [ linestart ] string foreground [ background ]
Context or keyword strings are interpreted, so that you can include tabs and spaces with the sequences \t and \s. Newlines and backslashes are specified with \n and \\ respectively. Since whitespace is used as a separator, it may not be used as is. Also, \* must be used to specify an asterisk. The * itself is a wildcard that matches any length of characters. For example,
colors all C single character constants green. You also could use
to color string constants, but the matched string would not be allowed to span across multiple newlines. The wildcard may be used within context delimiters as well, but you cannot have a wildcard as the last or first character.
Important to note is the line
This line defines a keyword containing the backslash and newline characters. Since the keywords are matched before the context delimiters, this keyword prevents the context from ending at the end of the lines that end in a backslash, thus allowing C preprocessor directive to continue across multiple lines.
The possible colors are: black, gray, red, brightred, green, brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta, cyan, brightcyan, lightgray and white. If the syntax file is shared with cooledit , it is possible to specify different colors for mcedit and cooledit by separating them with a slash, e.g.
mcedit uses the color before the slash. See cooledit(1) for supported cooledit colors.
Comments may be put on a separate line starting with the hash sign (#).
Because of the simplicity of the implementation, there are a few intricacies that will not be dealt with correctly but these are a minor irritation. On the whole, a broad spectrum of quite complicated situations are handled with these simple rules. It is a good idea to take a look at the syntax file to see some of the nifty tricks you can do with a little imagination. If you cannot get by with the rules I have coded, and you think you have a rule that would be useful, please email me with your request. However, do not ask for regular expression support, because this is flatly impossible.
A useful hint is to work with as much as possible with the things you can do rather than try to do things that this implementation cannot deal with. Also remember that the aim of syntax highlighting is to make programming less prone to error, not to make code look pretty.
COLORS
OPTIONS
/.mc/ini and have obvious counterparts in the dialog box. You can modify them to change the editor behavior, by editing the file. Unless specified, a 1 sets the option to on, and a 0 sets it to off, as is usual. use_internal_edit This option is ignored when invoking mcedit . editor_key_emulation 1 for Emacs keys, and 0 for normal Cooledit keys. editor_tab_spacing Interpret the tab character as being of this length. Default is 8. You should avoid using other than 8 since most other editors and text viewers assume a tab spacing of 8. Use editor_fake_half_tabs to simulate a smaller tab spacing. editor_fill_tabs_with_spaces Never insert a tab space. Rather insert spaces (ascii 20h) to fill to the desired tab size. editor_return_does_auto_indent Pressing return will tab across to match the indentation of the first line above that has text on it. editor_backspace_through_tabs Make a single backspace delete all the space to the left margin if there is no text between the cursor and the left margin. editor_fake_half_tabs This will emulate a half tab for those who want to program with a tab spacing of 4, but do not want the tab size changed from 8 (so that the code will be formatted the same when displayed by other programs). When editing between text and the left margin, moving and tabbing will be as though a tab space were 4, while actually using spaces and normal tabs for an optimal fill. When editing anywhere else, a normal tab is inserted. editor_option_save_mode Possible values 0, 1 and 2. The save mode (see the options menu also) allows you to change the method of saving a file. Quick save (0) saves the file by immediately, truncating the disk file to zero length (i.e. erasing it) and the writing the editor contents to the file. This method is fast, but dangerous, since a system error during a file save will leave the file only partially written, possibly rendering the data irretrievable. When saving, the safe save (1) option enables creation of a temporary file into which the file contents are first written. In the event of an problem, the original file is untouched. When the temporary file is successfully written, it is renamed to the name of the original file, thus replacing it. The safest method is create backups (2). Where a backup file is created before any changes are made. You can specify your own backup file extension in the dialog. Note that saving twice will replace your backup as well as your original file.
MISCELLANEOUS
The last line specifies that the third and then the second number are to be used in place of the first and second.
It is advisable to use this feature with Prompt On Replace on, because a match is thought to be found whenever the number of arguments found matches the number given, which is not always a real match. Scanf also treats whitespace as being elastic. Note that the scanf format %[ is very useful for scanning strings, and whitespace.
The editor also displays non-us characters (160+). When editing binary files, you should set display bits to 7 bits in the Midnight Commander options menu to keep the spacing clean.
FILES
/usr/share/mc/mc.ini The default system-wide setup for GNU Midnight Commander, used only if the user’s own
/.mc/ini file is missing.
/usr/share/mc/mc.lib Global settings for the Midnight Commander. Settings in this file affect all users, whether they have
/usr/share/mc/syntax/* The default system-wide syntax files for mcedit, used only if the corresponding user’s own
/.mc/cedit/ file is missing.
$HOME/.mc/ini User’s own setup. If this file is present then the setup is loaded from here instead of the system-wide setup file.
$HOME/.mc/cedit/ User’s own directory where block commands are processed and saved and user’s own syntax files are located.
Источник
Mcedit linux что это
тЕДБЛФПТ McEdit
рПМШЪПЧБФЕМЙ ЖБКМПЧПЗП НЕОЕДЦЕТБ Midnight Commander ПИПФОП ЙУРПМШЪХАФ ЧУФТПЕООЩК Ч ОЕЗП ТЕДБЛФПТ Mcedit. пДОБЛП, ПО УРПУПВЕО ЪБРХУЛБФШУС Й ЛБЛ УБНПУФПСФЕМШОПЕ РТЙМПЦЕОЙЕ, Ч ЬФПН УМХЮБЕ ФТЕВХЕФУС Ч ЛПНБОДОПН ПЛОЕ ОБВТБФШ "mcedit".
чОЕЫОЕ ЬФПФ ТЕДБЛФПТ ОБРПНЙОБЕФ ТЕДБЛФПТ Edit ЙЪ ОБВПТБ ХФЙМЙФ Norton Commander, ИПТПЫП ЙЪЧЕУФОЩК РПМШЪПЧБФЕМСН ЕЭЕ УП ЧТЕНЕО MS DOS.
рЕТЕНЕЭЕОЙЕ РП ДПЛХНЕОФХ ПУХЭЕУФЧМСЕФУС РТЙ РПНПЭЙ ЛМБЧЙЫ ХРТБЧМЕОЙС ЛХТУПТПН, Б ФБЛЦЕ У ЙУРПМШЪПЧБОЙЕН НЩЫЙ. дМС РЕТЕИПДБ ОБ ДТХЗХА УФТПЛХ УМХЦЙФ ЛМБЧЙЫБ Enter. чЩДЕМЕОЙЕ ЖТБЗНЕОФБ ФЕЛУФБ ПУХЭЕУФЧМСЕФУС У РПНПЭША НЩЫЙ.
ч ФБВМЙГЕ РЕТЕЮЙУМЕОЩ ОБЪОБЮЕОЙС РХОЛФПЧ НЕОА Й ОЕЛПФПТЩЕ ЛПНВЙОБГЙЙ ЛМБЧЙЫ ДМС ТБВПФЩ У ФЕЛУФПН.
Ctrl+y | хДБМЕОЙЕ УФТПЛЙ |
Ctrl+u | пФНЕОБ РПУМЕДОЕК ПРЕТБГЙЙ ТЕДБЛФЙТПЧБОЙС |
Ins | рЕТЕЛМАЮЕОЙЕ ЧУФБЧЛБ/ЪБНЕОБ (insert/overtype) |
F7 | рПЙУЛ (НПЦОП ЙУРПМШЪПЧБФШ ТЕЗХМСТОЩЕ ЧЩТБЦЕОЙС) |
Shift+F7 | рПЧФПТ РПУМЕДОЕК ПРЕТБГЙЙ РПЙУЛБ |
F4 | ъБНЕОБ |
F3 | рЕТЧПЕ ОБЦБФЙЕ — ОБЮБМП ПФНЕФЛЙ ВМПЛБ, ЧФПТПЕ — ЛПОЕГ |
F5 | лПРЙТПЧБОЙЕ ЧЩДЕМЕООПЗП ЖТБЗНЕОФБ |
F6 | рЕТЕНЕЭЕОЙЕ ЧЩДЕМЕООПЗП ЖТБЗНЕОФБ |
F8 | хДБМЕОЙЕ ФЕЛХЭЕК УФТПЛЙ |
Ctrl+f | ъБРЙУШ Ч ЖБКМ |
Shift+F5 | юФЕОЙЕ ЙЪ ЖБКМБ |
Shift+F4 | уПЪДБОЙЕ ОПЧПЗП ЖБКМБ |
F2 | уПИТБОЕОЙЕ ЖБКМБ |
F10 | ъБЧЕТЫЕОЙЕ ТБВПФЩ |
ъБДБОЙС
- ъБРХУФЙФЕ ЖБКМПЧЩК НЕОЕДЦЕТ mc Й РТПУНПФТЙФЕ УПДЕТЦЙНПЕ ЖБКМБ notepad.txt
- чПКДЙФЕ Ч ТЕЦЙН ТЕДБЛФЙТПЧБОЙС Й УЛПРЙТХКФЕ БОЗМЙКУЛЙК ЖТБЗНЕОФ ФЕЛУФБ ДЧБЦДЩ.
- уПИТБОЙФЕ ЖБКМ РПД ЙНЕОЕН medit.txt Й ЧЩКДЙФЕ ЙЪ ОЕЗП, ЪБЧЕТЫЙЧ ТБВПФХ У РТПЗТБННПК mc.
Источник
Пример использования макросов в редакторе mcedit
Преамбула
Я, как правило, редактирую исходний код во встроенном в mc (midnight commander) редакторе mcedit (не спрашивайте почему не в vim, так исторически сложилось). И уже довольно давно в mcedit можно пользоваться функцией записи и проигрывания макросов.
Макросами я пользуюсь постоянно, но это как правило довольно простые вещи, вроде замены одного текста на другой, или повторения каких то однопипных операций. Но в данном случае мне пришлось иметь дело написанием более сложного макроса, с реализацией которого и хотелось бы познакомить потенциального пользователя замечательного редактора mcedit.
Задача была открыть на редактирование файл содержащий проблему в котором по хоткею, т.е. приложив минимум усилий.
Т.е в редакторе был открыт файл со списоком предупреждений, который был сгенерирован утилитой doxygen, это был список содержащий полный путь к проблемному файлу а также номер строки.
Файл с предупреждениями выглядел примерно так (только строк было значительно больше):
Решение
В первую очередь, задача была разбита на две подзадачи:
1) выделить нужный участок текста от начала строки до двоеточия, включая номер строки;
2) обработать во внешней программе выделенный фрагмент;
Внешние макросы (external macros)
Другими словами, необходимо написать внешний макрос, который примет строку и откроет нужный файл на нужной строке.
Узнать где mcedit хранит внешние макросы можно коммандой:
в результате мы увидим следующий текст
Далее необходимо написать код внешнего обработчика и сохранить его с именем /home/smind/.local/share/mc/mcedit/macros.d/macro. .sh
Данное потребуется далее при написании макроса (в моём случае файл назывался macro.42.sh).
Файл внешнего макроса должен выглядеть примерно так
%b — имя файла содержащего выделенный в редакторе текст.
Макросы редактора (mcedit macros)
Для записи макроса достаточно нажать сочетание ctrl-r после чего дальнейшие нажатия клавишь будут записываться и смогут быть повторены.
Для окончания необходима еще раз нажать ctrl-r и далее нажать хоткей для вызова макроса.
Теперь нужно записать следующий макрос:
… и после окончания записи макроса повесить его на сочетание ctrl-P, после чего необходимо открыть файл храняший макросы /home/smind/.local/share/mc/mc.macros
В строчку, содержащую нужный макрос, необходимо добавить вызов внешнего макроса — ExecuteScript:42;
Должно получиться что то вроде этого:
Далее просто устанавливаем курсор на любую строку содержащую путь и нажимаем ctrl-p, произойдёт открытие файла по пути под курсором.
PS: надеюсь количество пользователей испольжующих макросы в mcedit ВНЕЗАПНО возрастёт.
PPS: на сочетание ctrl-F у меня повешено форматирование выделенного текста с помощью утилиты indent (очень удобно)
PPPS: извиняюсь за большое количество повторений слов «Далее» и «После»
Источник