Linux Programming

nano vs. Vim: The Best Terminal Text Editors, Compared

Bertel King Updated 25-05-2020

You may be surprised to learn that many aspects of your Linux desktop are not hidden behind complex code. Numerous programs and system settings are tucked away in text files.

Advertisement

You can open these with your default text editor such as Gedit or Kate, but the terminal is often faster, especially when you need administrator permissions.

For terminal-based text editing, two of the top choices are GNU nano and Vim. Which is better? I’m not going to wade into that question, but there are core differences that set these two text editors apart.

A Brief History of GNU nano and Vim

The GNU nano (more commonly referred to as “nano”) project was created in 1999 in order to emulate and improve upon the Pico text editor. Developers claimed GNU nano to be 2/3 to 1/8 the size of the Pico binary, which made it very lean and usable on even the weakest systems.

Vim, originally developed in 1991, is based on the original Vi text editor that was developed in 1976. Like GNU nano, Vim began as an effort to improve an earlier project.

GNU nano

Nano Linux terminal text editor

Advertisement

GNU nano has a reputation for being relatively user-friendly. If you’ve never used nano before, there’s a good chance you can fumble your way through without help.

To get started, you can open or create a file by typing:

nano /home/user/HelloWorld.txt

This will show you a recognizable user interface. The title of your text file appears at the top and the text contained within the file appears in the middle. The actions you can perform line the bottom. You complete these actions by pressing Ctrl plus the indicated key.

For example, you exit and save a file using Ctrl + X. Admittedly, 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 “Exit”. But when you try to edit, Nano asks if you want to save.

Advertisement

As the bottom of the screen shows, nano contains much of the functionality you would expect from a graphical application. You can cut and paste, find and replace words, and much more.

GNU nano’s features include:

  • Autoconf support
  • Goto-line# command w/o flag
  • Case sensitive search function
  • Interactive search and replace
  • Slang and ncurses support
  • Autoindent ability
  • Displayed tab width option
  • Regular expression search and replace
  • Toggles for cmdline flags via meta keys
  • Tab completion when reading/writing files
  • Soft text wrapping (text doesn’t wrap as in full-fledged document editors, with continuations indicated with $)

Overall, nano is a great option for newcomers to terminal text editing. You can get to try your hand at opening files from the command line and navigating using primarily a keyboard without having to throw out much of what you know about text editors.

On a DEB-based system such as Debian or Ubuntu, you can install GNU nano using:

sudo apt install nano

On Fedora, a RPM-based system, you can install using:

Advertisement
sudo dnf install nano

Since nano is a command-line program you likely won’t find it in GNOME Software or alternative Linux app stores. But you can install it using traditional package managers, such as Synaptic.

Vim

Vim Linux terminal text editor

Vim, by contrast, isn’t quite so welcoming to newcomers. When you open a text file you see just the contents of the file and no indication of how to use Vim itself.

Getting started is straightforward though. You open a file using the following command:

Advertisement
vim /home/user/HelloWorld.txt

At this point, you’re left having to read the documentation, search online, or mash buttons and hope for the best. If you do opt for the last option, there are some safeguards in place. You can’t do any real editing without pressing I to enter “Insert” mode. After you’ve made your edits, you then press Esc to exit the mode (at least you could probably guess that).

To perform other functions, when not in Insert mode, press the : (colon) key. Then type the key or keys that correspond with what you want to do and press Enter.

For example, to save the changes you’ve made to your text file, type :w and hit Enter. This will “write” changes to your file. See, the w is intuitive when you think in terms of read and write rather than open and save.

When you’re done, you can then type :q and hit Enter to quit the program. Again, rather intuitive.

Once you learn the behavior, there’s a certain beauty to Vim’s minimal aesthetic. You don’t have clutter floating inside your terminal window. All you see on screen is the text inside your text file. If you’re comfortable with typing (and you very well may be, considering you’re in the command line), Vim’s interface can feel rather natural.

There’s another reason to make the effort. Vim has the advantage of being more powerful than GNU nano. Not only does Vim contain more features from the get-go, you can also customize the program with plugins and scripts.

Vim’s features include:

  • Automatic commands
  • Completion commands
  • Digraph input
  • Higher memory limits than vanilla vi
  • Split screen
  • Session recovery
  • Tab expansion
  • Tag system
  • Syntax coloring

After you’ve taken the time to add in your desired plugins, Vim becomes a capable alternative to full-featured graphical text editors such as Sublime Text or Visual Studio Code. If you’re not into coding, that doesn’t mean it’s time to give Vim a pass. With a markdown plugin available, Vim is also a capable option for writers.

Is Vim harder to grasp than nano? For sure. But with the ability to add features from other text editors How to Add Top Features From Other Text Editors to Vim Using the Vim text editor but wishing it was as functional as other text editors? Here's how to install new features in Vim. Read More , you can really make Vim your own.

On Debian or Ubuntu, you can install Vim using:

sudo apt install vim

On Fedora, use:

sudo dnf install vim

GNU nano vs. Vim: Which Do You Prefer?

If you can live with with a steeper learning curve, then you may find yourself falling in love with Vim. It’s simple and rather attractive in its own way.

But if you want an option that’s straightforward and gets the job done, there’s little reason not to pick GNU nano. It doesn’t have the mystery that Vim has. You don’t have to read a manual to use the program, which in general is 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 ways to integrate plain text files 8 Everyday Things That You Can Track with Text Files Storing data in text files is a shortcut to a simpler workflow. Let's use the humble text file to track everyday data with these tips and improve our productivity. Read More into how you use your computer.

Related topics: GNU nano, Linux Tips, Product Comparison, Terminal, Text Editor, Vim.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. clangnerd
    June 11, 2020 at 2:08 pm

    You're comparing Nano to Vi(m) and naming Nano as one of two best editors on Terminal? Seriously? :D

  2. Clangnerd
    June 11, 2020 at 2:02 pm

    Nano is the one of two best terminal text editors? Really? :D How about Emacs? Joe? Vis? Nano really is really really basic, and while it's perceived simplicity might appeal some, it's certainly not comparable to any of these (or vim).

    If you're looking for simplicity, I think I'd go with Micro instead. It's feature set is comparable to that of Nanos, but in addiition it's got familiar keybingings, working unicode support and syntax hilighting.

    Joe is an editor that you can make "mimic" basically any other modeless editor. It's very compact and very capable, with things like inserting output of commands to the file you're editing or filtering files or blocks of text through shell commands (like xml linter or whatnot). Both of which are something that as far as I know Nano is unable to do (feel free to correct me if I'm wrong).

  3. steve
    March 30, 2017 at 3:13 pm

    uh... The command ':wq' saves and exits, so does ZZ in command mode. That's way faster than ctrl + x, y, enter

  4. Guest
    January 25, 2016 at 12:09 pm

    Windows version of Nano editor still does not support UTF-8. So it deprecates the use of Nano.

  5. PePas
    July 19, 2013 at 6:58 pm

    I used to be ashamed that I preferred 'ne', "the nice editor" to vim/emacs. But I recently discovered that it is utterly capable, very easy to use for newcomers yet very flexible and adaptable to experienced users. It comes with an easy menu system (that you are not forced to use, as you can set everything to key bindings), macros, yet it is only slightly larger than nano (and definitely more capable AND easier to use).

    Danny, could you perhaps do a review on 'ne' some time?? It is a superb editor that is still actively being developed, super easy to use and very powerful.

  6. Lee
    July 19, 2013 at 2:19 am

    You can also open Vim using the 'vim' command. I always thought that 'vim' would launch Vim, and 'vi' would still launch the older version, but I guess there wouldn't be a reason for Vi to be included with newer distros when they can include Vim.

    I'd be interested in seeing more about Emacs as well. I'm definitely more comfortable with Vim (I barely know any of the keyboard shortcuts for Emacs, to the point that I have to look up the shortcut to close it every time I try using it) but a lot of people seem to prefer Emacs.

    • David E
      July 19, 2013 at 6:55 pm

      vim has a graphical version, gvim that provides better support for mouse and screen usage.

      vim will also record your keystrokes so you can easily store and re-execute the same set of commands on different text regions.

      vim (actually vi) does have a steep learning curve. The upside of that is that, by default, it does not use any non-alphabetic keys except and .

      I also like emacs, particularly for running other programs (like gdb) under it while getting full editor control of the screen. My tongue-in-cheek take on emacs:
      "Emacs is great for everything, except editing - it is just OK at that"

      I don't have much experience with nano/pico.

    • Naveen
      July 20, 2013 at 3:31 pm

      Hi Andrew,

      I am planning to work on unix shell programming. So which is the best tool to work on the same. Also please let me know how to configure my pc as local server to write some unix network programs. Please advise.

      Thanks

      Naveen

  7. Damien
    July 19, 2013 at 12:49 am

    For nano, the shortcut key for saving is Ctrl + o, not ctrl + x. That is for exiting nano.

  8. Andrew
    July 18, 2013 at 8:53 pm

    Highly recommend grabbing some syntax highlighting .rc files for nano if you plan on using it quite a bit! These are the ones I used to use: https://github.com/scopatz/nanorc

    • Josh
      April 26, 2016 at 4:22 am

      thanks Andrew

  9. Howard J
    July 18, 2013 at 6:32 pm

    Good old fashioned vi all the way!

  10. Tyler
    July 18, 2013 at 6:26 pm

    Emacs forever! You'll never defeat us, never!!