Skip to main content

Vim vs. Nano vs. Emacs: Three sysadmins weigh in

Three editors. Three experts. Which Linux text editor is right for you?
Image
Vim, Emacs, Nano, and a panel of experts

Text editors. They aren't something that most users put a lot of thought into. However, not all text editors are alike, and with more time at the terminal, you might find that a particular editor works best for you. I asked several of our contributors to write up a "pro" position for Vim, Nano, and Emacs. Each text editor is represented by one contributor with a great deal of experience with the given editor. We are talking about features, comparisons, and personal experiences. Let's jump into the editors, with Vim up first.

[ You might also like: Sysadmin tools: Viewing text in Linux with tail and head ]

Vim - Ricardo Gerardi

Vim is a lightweight but powerful all-purpose text editor that addresses all your text editing needs, from basic configuration file editing to emulating entire Integrated Development Environments (IDE) for software development.

I've been using Vim in one way or another for over 20 years, but around five years ago, I decided to use Vim for all my text needs. I use Vim to write documentation, code in different programming languages, and I wrote an entire book (400+ pages) using Vim exclusively.

Vim's name is a contraction for Vi Improved as it extends the original vi text editor developed for the Unix operating system in the 1970s/80s. Vim has all the features you'd expect from a modern text editor, such as:

  • Undo/redo
  • Autocompletion
  • GUI mode
  • Search and replace
  • Built-in terminal
  • Built-in file manager
  • Spell check
  • Color schemes
  • Syntax highlight

I could list many other features, but this is not what makes Vim different. In my opinion, Vim is the best text editor out there due to a combination of other factors. Let's take a look at those below.

1. Vim is ubiquitous

Vim is everywhere. It's installed by default in most Linux distributions. If not, you can install it using your distribution's package manager. In addition, many distributions include Vim goodies such as plugins, extensions, and dictionaries with their standard package manager. Vim is also available for several other operating systems, including Unix, macOS, and Windows. Vim configuration is portable, and you can have the same Vim experience by copying your configuration files from one machine to another.

2. Vim is fast

Vim is lightweight and fast. Vim runs primarily on the terminal with a small footprint. Combined with a super-fast startup time and zero latency, you can use Vim anytime, anywhere, including over remote connections via SSH and low-powered hardware. You can even have multiple Vim sessions open at once without impacting your machine's performance.

3. Vim is keyboard-driven

Vim provides a keyboard-only experience. You can do everything in Vim without taking your hands off the keyboard. No context switching with the mouse improves your comfort and efficiency. It also allows a good experience when typing in restricted spaces such as when commuting on a train or bus.

4. Vim is intuitive

Vim provides simple and fast navigation commands. You can move your cursor with the arrow keys (or "h", "j", "k", "l" to keep your hand on the home row) like other text editors but, when you start using text objects, you increase your efficiency a lot. For example, pressing "w" takes you to the beginning of the next word, "b" back to the previous word, and "$" to the end of the line. You can also combine these with numbers to move faster. For example, "3w" moves to the beginning of the third word. Vim provides many of these navigation commands.

In addition to navigation commands, Vim provides intuitive mnemonics actions. For example, press "i" to insert text, "c" to change, "d" to delete, and so on.

The best part is you can combine these two ideas to create powerful command chains. For example, "dw" deletes all text until the next word, "d$" deletes until the end of the line, and "c3w" changes all text until the third word.

Vim structures these command chains semantically, reflecting our thought process, similar to sentences in English with verbs and objects. You can combine them logically to compose your own actions without requiring specific commands or functions; or memorizing some weird combinations of keys like Ctrl+Shift+F4 to perform actions.

When you first start with Vim, these commands feel awkward but, with a little practice, they make text editing highly efficient. In fact, Vim keybindings are so popular that other editors like Emacs and even many IDE's provide a way to enable/emulate them.

5. Vim is flexible and extensible

Vim is extremely flexible and powerful. You can start simple and use it to edit configuration files quickly. You can also write programs in your favorite programming language, with features like code completion, syntax highlighting, and syntax checking, similar to popular IDE's. Vim provides out-of-the-box syntax highlighting for many languages and file types.

Vim is fully customizable. You can provide options on the fly or through a config file. You can also create conditional configurations that are effective only when editing a particular type of file. In addition to customization, Vim supports plugins out of the box. The open-source community has developed several plugins to extend Vim's functionality even further. You can add code syntax for other languages, integrate with Git, add a fancy status bar, fuzzy finding, smart code commenting, code snippets, and many other features.

More than just a text editor, Vim is a platform that allows you to build your own text editing experience according to your requirements and preferences.

Want to learn more?

If you want to learn more about Vim, take a look at some of these links:

Final words on Vim

Vim is a fantastic text editor. It's fast, flexible, and powerful, but most of all, it's fun to use. I honestly don't see me doing some of the things that I can do in Vim with any other editor, at least not as efficiently.

I confess that Nano has saved my life on a couple of occasions, the most recent while I was writing a certification test and Vim's keybinds did not work due to limitations with the exam's web interface. Nano's simple nature allowed me to complete the test successfully.

I've never used Emacs, mostly because I never felt it would provide anything I couldn't do with Vim with a smaller footprint. Perhaps I'll give it a try someday but, until then, Vim continues to be the main driver for all my text editing requirements.

Needless to say, I wrote this blog post using Vim ;-)

Nano - Amy Marrich

Nano is a lightweight text editor, plain and simple. Its sole purpose is to let you edit text. In fact, it's so lightweight many *nix operating systems use it as the editor when in recovery mode.

Even with it being lightweight, it does have some more complex capabilities, though not to the extent that some of the other editors do. Then again, you don't need to install anything else to use it either.

Search

As already mentioned, other text editors are much more robust, but one feature I prefer by far in Nano is the search capability. Unlike most aspects of Linux, the search feature in Nano is not case sensitive by default though you can easily tell it to be. This comes in handy when you're looking for all instances of a word or if you're not sure what case the word is in.

Some other benefits of the search feature include:

  • Moving to specific locations within the document
  • Finding/replacing a word or words
  • The ability to search backward
  • The very handy fact it will wrap back to the top once it reaches the end of the document to continue the search

Other resources

Because Nano is lightweight and easy to use, there isn't much of a learning curve to get started, but here are some tutorials to dive in deeper:

Emacs - Seth Kenlon

GNU Emacs has all the usual features: Easy package installation (package-list-packages), easy theming (customize-themes), a GUI interface as well as a terminal-only interface, a builtin file manager (dired), split screens, remote editing, autosaves, and much more.

The keybindings are a little awkward, but no more so than playing the piano, and it's often just as fluid, especially on a Dvorak keyboard.

But I think it's a unique luxury to have one application that is also itself a live coding environment. The way GNU Emacs can redefine itself, and be redefined by the user, is its most powerful feature.

Lisp

I didn't start using Emacs intending to care about Lisp, much less to learn any of it. Even today, my .emacs configuration file is little more than a patchwork collection of other people's ingenious hacks. But the power within GNU Emacs is enticing, and a small hack in a config file can grow into a complex script that saves you hours during your workday.

With an only rudimentary knowledge of Lisp combined with functions already built into Emacs, I was able to move autosaves into a hidden directory, providing me with the comfort of not having to look at backup files but at the same time knowing that the backup files exist.

I haven't lost data in Emacs due to a crash or disconnection in years.

Lightweight Emacs

There's more to Emacs than GNU and Lisp, though.

The tradition of "emacsen" (that's the accepted plural form of more than one Emacs) pre-dates and continues beyond the GNU Emacs implementation.

There are many options for editors based around a collection of macros and a specific style of user experience, most of them more lightweight than the GNU editor.

Some of my favorites:

I use these emacsen and emacs-alikes almost as often as I use GNU Emacs because they're easy to compile and run from /home on servers where I don't have sudo privileges. They provide similar (or the same) keybindings I'm used to, access to macros and functions, and a familiar overall user experience. And because Emacs is such a big concept, it very often is also able to provide a familiar user experience for users of other editors.

You can use Vim keybindings in GNU Emacs with evil-mode, and you can mimic GNU Nano with Joe's jpico.

The Emacs world

The world of Emacs is a rich one, and as often as I try other editors, I have yet to find anything lacking in GNU Emacs.

Sure, I enjoy Vim for quick edits and its simple navigation, and I have a legitimately reverent appreciation for Nano's intuitive interface, but Emacs is the place I call home.

[ Getting started with containers? Check out this free course. Deploying containerized applications: A technical overview. ]

Decision time

Ok, so now you have to make a decision. Which of these text editors is going to be best for you? If you're like me, whichever is installed and easy to get to is the one I am using most often (Vim). However, I can't choose for you. The best advice I can give is to try out each editor for yourself and see which flavor you like best. Remember, the goal is to be efficient and comfortable with whichever editor you choose.

Check out these related articles on Enable Sysadmin

Topics:   Linux   Text editors  
Author’s photo

Tyler Carrigan

Tyler is a community manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! He was first introduced to Red Hat in 2012 by way of a Red Hat Enterprise Linux-based combat system inside the USS Georgia Missile Control Center. More about me

Author’s photo

Amy Marrich

Amy Marrich is a Principal Technical Marketing Manager at Red Hat. More about me

Author’s photo

Seth Kenlon

Seth Kenlon is a UNIX geek and free software enthusiast. More about me

Author’s photo

Ricardo Gerardi

Ricardo Gerardi is a Senior Consultant at Red Hat Canada where he specializes in IT automation with Ansible and OpenShift.  More about me

On Demand: Red Hat Summit 2021 Virtual Experience

Relive our April event with demos, keynotes, and technical sessions from
experts, all available on demand.

Related Content

OUR BEST CONTENT, DELIVERED TO YOUR INBOX