Console text editors are an indispensable tool in server management, providing the ability to create and edit text files. They are distinguished because they are based on the command line, devoid of graphical elements, but at the same time provide all the necessary options for effective work with text information. This tool can be useful both for small tasks, for example, changing one specific file, and for a full study of server logs on Linux.
In this article we will analyze several console text editors for Linux operating systems. Let's look at the most popular solutions, such as nano, vim, and also talk about less known ones: emacs, joe and micro. After reading, the user will have a general idea of all the listed editors, and will be able to choose the most optimal one for his dedicated or virtual server.
Nano text editor
Nano is one of the most popular terminal text editors for Linux systems. Unlike most other utilities, nano provides a unique benefit - it does not require a high level of professionalism to use. This console text editor is designed to be easy-to-use and intuitive, making it accessible even to beginners. In most cases, it is already preinstalled on the system. However, if it is not available, you can install the editor using the following commands:
For CentOS:
yum install nano
On Debian/Ubuntu:
apt install nano
You can use this command in order to open the file and further work in a text editor:
nano path/to/file
A list of basic commands for working with files is indicated at the bottom of the window. Just use the Ctrl key simultaneously with the desired function. The tool documentation can provide more detailed information.
To use a tool with options that do not appear in the terminal, use the syntax:
nano option path/to/file
A full list of available functions can also be found in the documentation at the link above. The main ones include the following:
+number
- specify the line in the file to start with--tabsize=digit
- set tabbing size in spaces--smooth
- enable smooth scrolling when moving through a file--mouse
- enable mouse support for navigation and text highlighting--autoindent
- automatically add indents when moving to a new line--wordwrap
- wrap lines by words, not by characters--softwrap
- wrap lines visually, without changing the actual text--syntax=language
- enable syntax highlighting for a specific programming language--bookmarks
- add bookmarks to quickly navigate through the file--multibuffer
- open multiple files in different buffers for simultaneous editing--linenumbers
- display line numbers in sidebar--rebindkey=key:command
- reassign a key to a specific command
It is important to mention that to enable or edit some functions you will need to use the configuration file located at /etc/nanorc. To enable or disable a function, you need to remove the comment function from the line (# symbol), and to make changes to a specific option - change the corresponding value.
Vim text editor
Vim — is an advanced console text editor, this is an improved version of the original vi, released in 1976. Its peculiarity lies in the unique concept of operating modes: normal, insertion and visual modes. It became famous for its efficiency in programming due to its extensive set of commands and support for regular phrasings for search and replace. Unlike simpler editors like nano, vim can take longer to become familiar with.
Installation on CentOS is done with the command:
yum install vim
On Debian/Ubuntu:
apt install vim
The program is launched and the required file is opened by command:
vim path/to/file
As you can see from the example above, code highlighting in vim is enabled by default. The program's functionality is very extensive, and file management occurs somewhat differently than in other editors. The developers have allocated a separate Help resource for a detailed study of all possible tools and commands.
Here, for example, is what the most common commands look like:
i
- go to insert mode to start entering textEsc
- exit insert mode and return to command mode (normal mode):w
- save the current file:q
- quit the current file:q!
- quit the current file without saving changesyy
– copy the current linedd
– cut the current linep
- paste the copied or cut line after the current oneu
- undo last action/search_term
– search of the search_term string in a file:s/old/new/g
- replace all instances of old with new in the current line:set number
- display line numbers
Vim is a powerful and flexible text editor designed to optimize the process of working with the text. The main disadvantage is the extremely high entry barrier for beginners. The interface and commands may be unfamiliar to those just starting to learn it, and this may lead into some difficulties in the beginning.
Emacs text editor
Emacs is a powerful and customizable text editor that provides a wide range of features for editing text, writing code, and managing files. It supports many programming languages, has built-in support for extensions (plugins), and allows the user to create their own scripts to automate tasks. Emacs also has a unique buffer and window management system, making it one of the most flexible and feature-rich editors around.
To install on CentOS, we will use the command:
yum install emacs
On Debian/Ubuntu:
apt install emacs
Opening a specific file in the console is similar to other editors:
emacs path/to/file
By default, syntax highlighting is disabled, and the appearance is practically no different from other console editors. At the bottom of the screen there is a status bar, and the main functionality is at the top. However, when working with the console version of the editor, this functionality is only available using a keyboard shortcut. It is important to note that the auxiliary keys used are the Control key, which is set to Ctrl by default, and the Meta key, set to Alt. The documentation page on the official website will help you to get acquainted with the full functionality.
As an example, let's check the most used commands:
Alt+X
– type a commandCtrl+X Ctrl+C
- close editorCtrl+G
- cancel the actionCtrl+H b
– show shortcut keysCtrl+X Ctrl+S
–save fileCtrl+X Ctrl+F
– open fileAlt+W
- copyCtrl+W
- cutCtrl+Y
- pasteCtrl+X 2
- split window verticallyCtrl+X 0
- switch between windowsCtrl+X -> Ctrl+X <
- switch between buffers
To summarize, emacs provides unique features such as a flexible command system, high customization, and extensive functional solutions. Its command line and macros allow users to create highly operating processes. However, due to its inherently extremely flexible structure, it is not recommended for use by beginners.
Joe text editor
Joe is a console-based text editor created by Joseph Ellis. It provides a simple and intuitive interface, ideal for working in a text console. Joe provides basic text editing functions such as inserting, deleting, copying, as well as advanced features including support for multiple programming languages with syntax highlighting. Like nano, this editor is an ideal choice for those who value usability.
Command to install on CentOS:
yum install joe
On Debian/Ubuntu:
apt install joe
A text file is opened by the command:
joe path/to/file
Syntax highlighting is activated by default, and basic information about the file being edited is displayed at the top of the editor. Like the previous editors, joe has many additional options, including support for macro commands. To become familiar with the basic set of commands, you need to use the key combination Ctrl+K, and then the H key. The available functions will be displayed at the top of the terminal:
A more detailed list of features can be found on the documentation page.
Joe has a simple and intuitive interface, making it accessible to beginners. At the same time, it provides powerful features such as multi-window support, text highlighting, searching and replacement, making it attractive to skilled users. The disadvantage of joe is that it lacks widespread support and development compared to other text editors, which may result in limited features and updates in the future. Users may also encounter difficulties in mastering features and key combinations when switching from other solutions.
Micro text editor
Micro — is a lightweight, easy-to-use text editor designed with a focus on minimalism and intuitivity. This tool provides basic text editing functionality and supports additional functionality extensions. Micro supports syntax highlighting for various programming languages, multi-line highlighting, plugin support and other customizable user settings.
Installation on CentOS is conducted by using a special script with the command:
curl https://getmic.ro | bash
On Debian/Ubuntu:
apt install micro
Please note: using this installation method, launching the editor on CentOS will also be different. You can open a specific file while in your home directory with the command:
./micro path/to/file
To use the tool from any directory, you need to move it to /usr/bin. To do this we will use the command
mv micro /usr/bin/
After which, the micro launch process will be similar on all Linux systems, including Debian/Ubuntu:
micro path/to/file
Keys for navigating and editing a document can be learned by pressing Alt+G. The most used commands will be displayed at the bottom of the terminal:
The Ctlr+G combination will open the complete help section of the tool:
You can learn more about the tool capabilities on the official GitHub project page in the documentation section.
Overall, the micro editor is an excellent choice for those who are used to lightness and usability. Its minimalistic design and fast performance make it an attractive tool for programmers. However, the disadvantage may be the limited set of functions and the lack of a graphical interface. Despite this, micro editor remains a reliable and efficient solution for text files editing
Conclusion
The review of text console editors for Linux revealed the diversity and unique characteristics of each of them. The lack of the only right solution emphasizes the importance of individual choice, allowing users to adapt their experience to suit their preferences and requirements. A wide selection of console text editors for Linux gives users the opportunity to customize the tool to their needs, highlighting the flexibility and diversity in the world of word processing.