It may surprise you that many aspects of your Linux desktop are not hidden behind complex code. Numerous programs and system settings are hidden in text files.
You can open it with your standard text editor like Gedit or Kate, but the terminal is often faster, especially if you need administrator rights.
Two of the most important options are available for terminal-based text editing: GNU nano and Vim. Which one is better? I am not going to deal with this question, but there are significant differences that distinguish these two text editors.
A brief history of GNU Nano and Vim
The GNU Nano Project (better known as "Nano") was created in 1999 to emulate and improve the Pico text editor. Developers claimed that GNU nano was 2/3 to 1/8 the size of the pico binary, which made it very slim and usable even on the weakest systems.
Vim, originally developed in 1991, is based on the original Vi text editor, which was developed in 1976. Like GNU nano, Vim started trying to improve a previous project.
GNU nano has a reputation for being relatively user-friendly. If you have never used nano before, there is a good chance that you can get away with it without help.
To begin, you can open or create a file by typing:
This shows you a recognizable user interface. The title of your text file is shown at the top and the text contained in the file in the middle. The actions you can take are at the bottom. You perform these actions by pressing Ctrl plus the given key.
For example, end and save a file with Ctrl + X.. Granted, I was very concerned about how to save my file the first time I used nano, as the text editor only lists this command as "Quit". However, when you try to edit, Nano asks if you want to save.
As the bottom of the screen shows, Nano contains most of the features you would expect from a graphical application. You can cut and paste words, search and replace, and more.
The functions of GNU nano include:
- Autoconf support
- Go to line # command with no flag
- Note upper and lower case
- Interactive search and replace
- Support slang and ncurses
- Autoindent ability
- Option for the displayed tab width
- Find and replace regular expressions
- Toggles the cmdline flags using meta keys
- Tab completion when reading / writing files
- Soft text wrapping (text is not wrapped like in full document editors, continuations marked with $)
Overall, Nano is a great option for newbies in terminal text editing. You can try opening files from the command line and mostly navigating with a keyboard without having to throw away much of what you know about text editors.
On a DEB based system like Debian or Ubuntu you can install GNU nano by:
sudo apt install nano
On Fedora, an RPM-based system, you can install:
sudo dnf install nano
Since nano is a command line utility, you probably won't find it in GNOME software or alternative Linux app stores. However, you can install it with traditional package managers like Synaptic.
In contrast, Vim isn't quite as inviting for newcomers. When you open a text file, you see only the contents of the file and no indication of how you are using Vim.
However, getting started is straightforward. You open a file with the following command:
At this point, all you have to do is read the documentation, search online, or crush buttons and hope for the best. If you choose the last option, there are some safety precautions. You cannot do real editing without pressing I to get into insert mode. After making your changes, press Esc to exit mode (at least you could probably guess that).
To perform other functions, press the key when you are not in insert mode :: (Colon) key. Then enter the key (s) that correspond to what you want to do and press Enter.
For example, type to save the changes you made to your text file : w and hit Enter. This will "write" changes to your file. See that w is intuitive when you think about reading and writing instead of opening and saving.
When you're done, you can type : q and hit Enter to end the program. Quite intuitive again.
Once you've learned the behavior, Vim's minimal aesthetics have a certain beauty. There is no mess in your terminal window. All you see on the screen is the text in your text file. When you're familiar with typing (and possibly when you're on the command line), Vim's interface can feel pretty natural.
There is another reason to make an effort. Vim has the advantage of being more powerful than GNU Nano. Vim not only includes more features from the start, you can also customize the program with plugins and scripts.
Vim features include:
- Automatic commands
- Closing orders
- Digraph input
- Storage limits higher than vanilla vi
- Split screen
- Session recovery
- Tab extension
- Tag system
- Syntax coloring
After taking the time to add the plugins you want, Vim becomes a powerful alternative to fully featured graphical text editors like Sublime Text or Visual Studio Code. If you're not interested in coding, it doesn't mean it's time to give Vim a pass. With an available markdown plugin, Vim is also a powerful option for authors.
Is Vim harder to grasp than nano? For sure. But with the ability to add functions from other text editors
How to add Vim top features from other text editors
you can really make Vim your own.
On Debian or Ubuntu you can install Vim with:
sudo apt install vim
Use on Fedora:
sudo dnf install vim
GNU nano vs. Vim: What do you prefer?
If you can live with a steeper learning curve, you might fall in love with Vim. It's simple and pretty attractive in its own way.
However, if you want an option that is straightforward and does the job, there is little reason not to choose GNU nano. It doesn't have the secret that Vim has. You do not have to read a manual to use the program. This is generally a hallmark of good design.
Ultimately, both are equally able to edit the same text files. And if you fall in love with one of the two programs, you will find ways to integrate simple text files here
8 Everyday Things You Can Track With Text Files
how to use your computer.