The operating system Linux has a wide range of text editing programs in the system that can be used by logging into the server via ssh. Among them are both simple ones (such as nano) and complex ones (vim, emacs). Here we will consider the text editor mcedit, which is installed together with the file manager Midnight Commander. Its name stands for Midnight Commander Editor.
To install Midnight Commander, log in to the server using the PuTTY program or the built-in ssh program and execute one of the following commands depending on the distribution. For deb-like:
apt install mc
yum install mc
The program Midnight Commander looks like this. For instructions on how to use it, please refer to the article in our blog.
Here you can select a file that you want to edit using F4 or create a new one by pressing SHIFT+F4. If there are multiple editors installed on the system, you need to select the one you want to use first. Choose mcedit. If another editor is already selected, click with the mouse (or press F9) in the top menu bar Options - Configuration and check the box Use internal edit (with the mouse or the space button) and then click OK at the bottom.
You can also launch the editor from the command line. To do this, execute one of the following commands:
The program looks like this:
In the center, there is a large field for entering text. At the bottom, there is a cheat sheet of possible commands.
At the top, there is a status bar. But if you click on this field with the left mouse button or press the F9 button, the program's menu panel will open. This menu is similar to the menu of regular graphical text editors, such as the Notepad program in Windows.
For example, in the Options - General menu, you can enable the Dynamic paragraphing option for word wrapping. Then use Options - Save setup to save the settings for subsequent application launches.
The program has all the necessary features for text editing. You can get help by pressing the F1 key. After finishing work with the program, press F2 to save and F10 to exit.
To search, press the F7 key. Enter the word or phrase to search for, as well as parameters such as reverse search and others. To search for the next occurrence of the word or phrase, press SHIFT+F7.
You can also perform replacement. To do this, place the cursor at the beginning of the document or from the line where you want to start the replacement and press F4. The replacement window will appear:
Then you will have the option to choose: replace, skip, or replace all.
To undo an action, press the CTRL+U combination, and to redo, press ALT+R.
In the editor, you can also select a text fragment and perform some actions on it. To select a fragment, place the cursor at its beginning and press F3. Move the cursor to the end of the fragment (next to the last selected character) and press F3 again. Then place the cursor in the desired position in the document and press F5 to copy the selected fragment or F6 to move it (acts as cut and paste).
In this way, we have examined the basic capabilities of the text editor mcedit, which allows you to create and edit files on servers with Linux operating systems.