Knowing how to edit files quickly and effectively via the command line is vital for every Linux system administrator. File edits are performed on a daily basis, whether it’s a configuration file, user file, text document, or whatever file you need to edit.
It’s a good idea to choose a favorite command-line text editor and master it. While it’s beneficial to know how to use various text editors, mastering at least one is essential for handling more complex tasks.
In this tutorial, we will introduce you to the most common command-line text editors in Linux and discuss their pros and cons.
However, we will not provide a comprehensive guide on how to work with each one of them, as that could be an entirely separate article with detailed explanations.
1. Vi/Vim Editor
First in our list is the infamous Vi/Vim (Vim comes from Vi improved), which is a very flexible text editor that can perform many different operations on text.
For example, you can use regular expressions in Vim to replace text snippets within a file. This, of course, isn’t its only advantage, it also offers easy navigation between lines, words, paragraphs, and text highlighting.
Vim may not be the most user-friendly text editor, but it is often preferred by developers and Linux power users. If you want to install the Vim command line text editor on your system, you can use the command associated with your Linux distribution:
Install Vi/Vim Editor in Linux
$ sudo apt install vim [On Debian, Ubuntu and Mint] $ sudo yum install vim [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] $ sudo emerge -a sys-apps/vim [On Gentoo Linux] $ sudo apk add vim [On Alpine Linux] $ sudo pacman -S vim [On Arch Linux] $ sudo zypper install vim [On OpenSUSE]
If you’d like to view our comprehensive coverage of Vim, please refer to the links below:
2. Nano Editor
Nano is probably one of the most used command-line text editors. The reason for this is its simplicity and the fact that it’s preinstalled in most of the Linux distributions.
Nano doesn’t have Vim’s flexibility, but it will definitely do the work if you need to edit a large file. Actually, pico and nano are quite similar.
Both have their command options displayed at the bottom so you can choose which one to run. Commands are completed with key combinations of Ctrl and a letter displayed at the bottom.
Nano has the following features that you can use out of the box:
- Get Help
- Write out
- Justify
- Read File
- Where is (search)
- Previous page
- Next page
- Cut Text
- Uncut Text
- Cur Pos (Current position)
- Spell check
Install Nano Editor in Linux
$ sudo apt install nano [On Debian, Ubuntu and Mint] $ sudo yum install nano [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] $ sudo emerge -a sys-apps/nano [On Gentoo Linux] $ sudo apk add nano [On Alpine Linux] $ sudo pacman -S nano [On Arch Linux] $ sudo zypper install nano [On OpenSUSE]
You can refer to our comprehensive guide on editing files with the Nano editor in the Linux command line.
3. Emacs Editor
This is probably the most complex text editor on our list. It’s the oldest command line editor available for both Linux and UNIX-based systems. Emacs can help you be more productive by providing an integrated environment for different kinds of tasks.
At first, the user interface may look somehow confusing. The good thing is that emacs has a very detailed manual that will help you with file navigation, edits, customization, and setting up commands. Emacs is the ultimate tool used by advanced *Nix users.
Here are some of the features that make it the preferred choice over the previous editors we mentioned:
- The Emacs server platform enables multiple hosts to connect to the same Emacs server and share the buffer list.
- Powerful and extensible file manager.
- Customization beyond a regular editor – as some say it’s an OS within the OS.
- Commands customization.
- Can change to Vi(m) like mode.
Install Emacs Editor in Linux
Emacs is a multi-platform editor and can be easily installed with the commands shown below:
$ sudo apt install emacs [On Debian, Ubuntu and Mint] $ sudo yum install emacs [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] $ sudo emerge -a sys-apps/emacs [On Gentoo Linux] $ sudo apk add emacs [On Alpine Linux] $ sudo pacman -S emacs [On Arch Linux] $ sudo zypper install emacs [On OpenSUSE]
4. Micro Text Editor
Micro is a modern and intuitive terminal-based text editor that bridges the gap between traditional command-line editors and contemporary user expectations.
Unlike the steep learning curves associated with editors like Vim or Emacs, Micro offers a more user-friendly approach, making it accessible to both novices and experienced users.
One of Micro’s standout features is its support for mouse functionality, allowing users to select, copy, and paste text just as they would in a graphical editor.
Additionally, it boasts a robust plugin system, enabling users to extend its capabilities according to their needs. Syntax highlighting, split panes, and customizable keybindings further enhance its appeal.
In essence, Micro Editor encapsulates the best of both worlds: the power and efficiency of terminal editing, combined with the ease and familiarity of modern text editors.
Install Micro Editor in Linux
There’s a useful script that can install ‘Micro‘ for you by downloading the latest prebuilt binary using the curl command as shown.
$ curl https://getmic.ro | bash
The script will install the micro binary to the current directory.
5. ne (nice editor)
The “ne” text editor, which stands for “Nice Editor” is a lightweight, user-friendly editor for the terminal that was designed to bridge the gap between simple editors like “nano” and more complex ones like “vim” or “emacs“.
Install ne in Linux
ne is a multi-platform editor and can be easily installed with the commands shown below:
$ sudo apt install ne [On Debian, Ubuntu and Mint] $ sudo yum install ne [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] $ sudo emerge -a sys-apps/ne [On Gentoo Linux] $ sudo apk add ne [On Alpine Linux] $ sudo pacman -S ne [On Arch Linux] $ sudo zypper install ne [On OpenSUSE]
Conclusion
There are other command line editors, but they barely even reach the functionality that the above 3 provide. Whether you are a Linux newbie or a Linux guru, you will most definitely need to learn at least one of the above-mentioned editors.
If we’ve missed any command-line editor in this article, please don’t forget to inform us via comments.
My favorite terminal editor (lightweight, usability, and features) is “ne“, which is good for both experienced users and beginners.
@Antonio,
Thank you for sharing your favorite terminal editor, “ne“. It’s great to hear that it’s lightweight, user-friendly, and has useful features that cater to both experienced users and beginners.
It’s always helpful to have recommendations from experienced users like yourself. Based on the search results, “ne” seems to be a popular and well-regarded terminal text editor and a good alternative to vi editor.
I use jstar, because it works similarly to WordStar, which was the important word processor in 1988 running under cp/m before msdos appeared.
Unfortunately, I didn’t find a similar editor for Windows
The one I use is Micro.
A lot of people recommended it to me since I was a die-hard GNU/Nano fan.
@Anika,
I’ve heard great things about Micro too! It’s always interesting to see how different text editors cater to different user needs.
How has your experience been transitioning from GNU/Nano to Micro?
I heard about Micro on the Linux Matter podcasts and decided to give it a try. Was pleasantly surprised as to its simplicity and power. It’s now my go-to text editor.
I could never get 100% comfortable with Nano and mainly used Vim prior to that. Dabbled in Emacs a way back, but it was way too complex for the small tasks I needed a text editor to perform.
While I use vim regularly, I’m also fond of NotepadQQ which is awesome as a text editor, and comes with all manner of extensions and add-ons! Great and informative article!!
@Eddie,
Never heard about NotepadQQ text editor, thanks for notifying. I will include NotepadQQ to the article.
Always use mcedit.
@Leon,
But MCEdit only available to Windows and Mac, no Linux version..
My all time favourite – Midnight Commander (MC) is a text-based program for Linux.
Just a tiny addition. EMACS is up to 25, so you need to update the command for Mint 17. I’d strongly recommend 25 since there’s a bug in 24 that has caused problems.
Nowadays neovim is solid choice. New contenders like kakoune also offer nice alternatives based on modal editing.
I also use pico, very usefull ;-)