You may be surprised to hear that many aspects of the Linux desktop are not hidden behind complex code. Numerous programs and System Preferences are hidden in text files.
You can open these with a default text editor like Gedit or Kate, but the terminal is often faster, especially when you need administrator privileges.
In terminal-based word processing, the two main options are GNU nano and Vim. Which one is better? I’m not going to wade into this question, but there are key differences that separate these two text editors.
A brief history of GNU nano and Vim
The GNU nano project (more commonly known as nano) was created in 1999 to emulate and improve Pico text editor. The developers claimed that the GNU nano was 2/3 to 1/8 the size of a Pico binary, which made it very narrow and usable even in the weakest systems.
Vim, originally developed in 1991, is based on the original Vi text editor, developed in 1976. Like GNU nano, Vim began its efforts to improve on an earlier project.
GNU nano has a reputation for being relatively user-friendly. If you’ve never used a nano before, there’s a good chance you’re scrolling your way through without help.
To get started, open or create a file by typing:
This will show you a recognizable interface. The title of the text file appears at the top and the text in the file appears in the center. The functions you can perform are at the bottom. To perform these operations, press Ctrl plus the assigned key.
For example, you can exit and save the file using Ctrl + X. True, I was very worried about how to save my file the first time I used nano, because in a text editor, this command is just “Exit”. But when you try to edit, the Nano asks if you want to save.
As shown at the bottom of the screen, the nano contains much of the functionality you would expect from a graphics application. You can cut and paste, find and replace words and more.
Features of GNU nano include:
- Autoconf support
- Goto-line # command without flag
- Font-sensitive search
- Interactive search and replacement
- Slang and ncurses support
- Autdentdent ability
- Tab width setting displayed
- Regular expression search and replacement
- Toggle cmdline flags with meta keys
- Completing the tab when reading / writing files
- Wrapping soft text (text wraps only as a full-time document editor, extensions are marked with $)
Overall, the nano is a great option for beginners to edit terminal text. You can try your hand at opening files from the command line and navigating mainly using the keyboard without having to throw out a lot of what you know from a text editor.
On a DEB-based system such as Debian or Ubuntu, you can install GNU nano using:
sudo apt install nano
In an RPM-based Fedora system, you can install:
sudo dnf install nano
Because nano is a command line program, you probably won’t find it in GNOME software or alternative Linux application stores. But you can install it using traditional package management programs like Synaptic.
Vim, on the other hand, is not quite as desirable for newcomers. When you open a text file, you only see the contents of the file and no instructions for using Vim itself.
However, getting started is simple. To open the file, use the following command:
At this point, you don’t have to read the documentation, search the web, or put together buttons and hope for the best. If you select the last option, some security measures are in place. You cannot make any actual edits without pressing I to enter the “Add” mode. When you have made your changes, you press exit to exit the mode (at least you can probably guess it).
To use other functions when you are not in Insert mode, press : (colon) key. Then enter the key or keys that correspond to what you want to do and press Come in.
For example, type a text file to save the changes you have made to your text file : weight and hit Come in. This “writes” the changes to the file. Look, w is intuitive when you think of reading and writing rather than open and save.
When you are done, you can then write q and hit Come in end the program. Again quite intuitive.
Once you have learned the behavior, Vimi’s minimal aesthetics are associated with a certain beauty. You have no clutter inside the floating end window. All you see on the screen is the text inside the text file. If you’re comfortable typing (and you’re fine when you’re on the command line), Vim’s interface can feel pretty natural.
There is another reason for the effort. The advantage of Vim is that it is more powerful than GNU nano. Not only does Vim include other get-go features, but you can also customize the program with extensions and scripts.
Vim features include:
- Automatic commands
- performance commands
- Digraph input
- Larger memory limits than vanilla vi
- Split screen
- Resuming a session
- Tab extension
- Tag System
- Syntax Coloring
Once you’ve taken the time to add the extensions you want, Vim becomes a possible option for any functional graphical text editor, such as Sublime Text or Visual Studio Code. If you’re not coding, that doesn’t mean it’s time to give Vim a pass. Because a notation extension is available, Vim is also a useful option for writers.
Is Vim harder to understand than nano? Certainly. But with ability add features from other text editors
How to add key features from other text editors to Vim
, you can really make Vim your own.
In Debian or Ubuntu you can install Vim using:
sudo apt install vim
Use with Fedora:
sudo dnf install vim
GNU nano vs. Vim: what do you prefer?
If you can live with a steeper learning curve, you may have to fall in love with Vimi. It’s simple in its own way and quite attractive.
But if you want an option that is clear and gets the job done, there is no reason not to leave GNU nano. It has no secret that Vim has. You do not need to read the manual to use the program, which is usually a hallmark of good design.
At the end of the day, both are equally capable of editing the same text files. And when you find yourself falling in love with either program, here are the ways integrate clear text files
8 daily things you can keep track of with text files
how you use your computer.