Emacs and Vim - A Basic Overview For Beginners in Software Engineering
Tags: emac, vim, linux, softwareengineering
Published: 2022-02-24 12:06:23

## Introduction
You've probably never heard of emacs or Vim, especially if you're just starting out your career in software engineering.

It is also normal that as a windows Operating System user, you've only been working with the notepad, notepad++, sublime text, visual studio code, and all other common text editors.

In the Linux operating system, Emacs and vi are the major editors that are used to manipulate files. Both are the major gladiators in the popular editor wars that started in the late 90s. 

Nowadays, the hottest contenders in tech software are web browsers. Internet Explorer, Firefox, and Chrome are competing for a larger market in the figurative browser war.

Holy wars are also existing in every sphere of life, especially in pop culture: iPhone vs Android, Marvel vs DC, Coke vs Pepsi, and so on. 

![Pop Culture Wars](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sdli4m8pm3p7y98wbukr.png)
 

## Text Editor Wars

The editor war is the rivalry between users of the Emacs and vi (now usually Vim, or more recently Neovim) text editors. The rivalry has become a lasting part of hacker culture and the free software community.

Since at least 1985, The Emacs versus vi debate was one of the original "holy wars" even before the internet. Many users insisted that their editor of choice is the paragon of editing perfection, and insulting the other. Similar tech battles have been fought over operating systems, programming languages, version control systems, and even source code indent style.

We are going to look at both editors and analyze their features and jargon.

## Emacs

**[Emacs (Editor Macros)](https://www.linuxfordevices.com/tutorials/linux/emacs-editor-tutorial)** was developed by David A Moon in 1976 making it one of the oldest pieces of software which exists today. GNU Emacs, the most used variant(fork) of Emacs, was released in 1985 by Richard Stallman, the founder of GNU/Linux.

![A Quote of Richard Stallman, the founder of GNU/Linux](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yey5phikt92isuffcjlv.png)

[Emacs](https://www.gnu.org/software/emacs/) is a highly advanced, extensible, and customizable text editor that also offers an interpretation of the Lisp programming language at its core. Different extensions can be added to support text editing functionalities. 

Emacs has the following features:

- User documentation and tutorials
- Syntax highlighting using colors even for plain text.
- Unicode supports many natural languages.
- Various extensions including mail and news, debugger interface, calendar, and many more.

![Emacs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mho3xye0gll1nplcz72h.png) 

You can find basic emac commands [here](https://web.physics.ucsb.edu/~pcs/apps/editors/emacs-basics.html)

## Vi(m)

**[Vim (Vi Improved)](https://www.linuxfordevices.com/tutorials/linux/vim-tutorial)**, as the name suggests is an improved clone of the text editor. The text editor was originally developed by Billy Joy in 1976 for the proprietary Unix operating system. Bram Moolenar later enhanced `vi` and released it as `vim` in 1991.

![Vi](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4736pqporcvv88kz9ud8.png)
 
[Vim](https://www.tecmint.com/install-vim-in-linux/) is a powerful command-line-based text editor that has enhanced the functionalities of the old Unix [Vi text editor](https://www.tecmint.com/vi-editor-usage/). It is one the most popular and widely used text editors among System Administrators and programmers that is why many users often refer to it as a programmer’s editor. It [enables syntax highlighting](https://www.tecmint.com/enable-syntax-highlighting-in-vi-editor/) when writing code or editing configuration files. 

The UNIX vi editor is a full-screen editor and has two modes of operation:

1. *Command mode* commands which cause action to be taken on the file, and

2. *Insert mode* in which entered text is inserted into the file. In the command mode, every character typed is a command that does something to the text file being edited; a character typed in the command mode may even cause the vi editor to enter the insert mode. 

In the insert mode, every character typed is added to the text in the file; pressing the <Esc> (*Escape*) key turns off the Insert mode.

While there are several vi commands, just a handful of these is usually sufficient for beginning vi users.

You can find basic vi commands [here](https://www.cs.colostate.edu/helpdocs/vi.html)

Vim is also used with Kubernetes for Developer Operations (devops) [expecially the Certified Kubernetes Application Developer Exam] (https://blog.getambassador.io/ckad-exam-tips-how-to-use-the-vim-editor-2be2a3283327?hss_channel=lcp-9320816&utm_content=200401193&utm_medium=social&utm_source=linkedin&gi=e5047caef4d2)

## Similarities between Emacs and Vi

1. The buffer tabs are supported in both the command line and graphical user interface.
2. Cross-platform text editors, including Unix, Linux, and Microsoft Windows.
3. Available in English, Chinese, French, Italian, Polish, Russian, and even more languages.

## Differences between Emacs and Vi

1. User Interface and Environment

Vim uses editing modes - most commonly the *command mode* and *insert mode*. Vim aims to minimize the number of keystrokes that a user has to press, because [vi](http://en.wikipedia.org/wiki/Vi), upon which Vim is based, was designed to be used over slow terminals.

Emacs uses modifier keys to enable shortcuts, which often involves pressing several keys simultaneously for a single function. This aspect of Emacs is often criticized.

As computer technology developed, new advancements like the GUI (Graphical User Interface) were developed. Emacs adapted and developed its own GUI to make it easier for people to learn and use the editor. In comparison, Vi did not develop its own GUI. This is partly due to the appearance of Vi variants that took over. 

A good example is Vi iMproved, also known as Vim, which gradually became more popular than Vi as it added more features and improvements that are not found in Vi. There are also variants of Emacs, but those have not caused the software to fall by the wayside.

2. Ease of Learning

Emacs is easier to learn since it has a more natural interface (for users familiar with GUI-based text editors). Since Vim has different editing modes, beginners find it a little harder to learn.

3. Productivity and Editing Speed

The main difference between the two is speed. Vi has historically [been](http://www.differencebetween.net/language/difference-between-been-and-gone/) the faster of the two starting up in less [time](http://www.differencebetween.net/miscellaneous/difference-between-mountain-time-and-eastern-time/) and is just generally the more responsive of the two. 

Vim enthusiasts argue that once a user becomes familiar with the editing modes and commands of Vim, it enables far greater productivity and efficiency. File editing is usually faster with Vim than with Emacs because of Vim's purposely speed-driven interface. For example, cursor movement can be controlled through the *H*, *J*, *K*, and *L* keys in the *normal mode*. This means the user's hands do not need to leave the "home row" position, which improves efficiency but comes at the price of adding overhead as mode switching is required to choose between movement and text editing. 

In Emacs (with the default configuration), the user moves the cursor with the Ctrl-B or Ctrl-F shortcuts, which might slow down the novice user since two keys need to be pressed. Productivity and efficiency improvements in Emacs depend upon the configuration of the editing environment rather than the editor itself.

4. RAM usage of Emacs vs Vim

Vi also takes up much less memory than Emacs; this is at a time when 8MB is considered to be a huge amount of RAM. Vim is lighter than Emacs and uses less memory. Vim advocates criticize Emacs' resource consumption with the tongue-in-cheek suggestion that Emacs stands for "Eighty [Megabytes](https://www.diffen.com/difference/KB_vs_MB) And Constantly Swapping".

However, with GNUclient, a single persistent Emacs process can be run that can support several clients simultaneously. This speeds startup time and decreases total memory usage, closing the gap between Emacs and Vim.

5. Extensibility and Customization of Emacs vs Vim

The [advantage](http://www.differencebetween.net/business/difference-between-absolute-and-comparative-advantage/) of Emacs over Vi is its extensive customizability. Emacs lets the user choose from a wide variety of macros to integrate into his workflow and reduce the effort needed in his process. 

Vi lacks this level of customizability and relies on its simplistic and straightforward process. Emacs is also capable of emulating Vi in what they [call](http://www.differencebetween.net/business/finance-business-2/difference-between-call-and-put/) “viper mode”; thereby making it easier for Vi users to use Emacs. Vi, with its simplicity, lacks such capabilities.

While both Vim and Emacs support plugins that enhance their functionality, Emacs supports a lot more customization of the editor environment. This is arguably the most important feature of emacs and is responsible for much of emacs' devoted following.

![Living in world of emacs as a vi fan](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gt8ee9w3o69iae3708qg.png)

Emacs can be extended on the fly by redefining built-in elisp functions, either by typing the new definition into Emacs or by loading elisp files. Groups of related changes are called "modes" and can be easily configured to be automatically used for particular types of files (buffers). So it is easy to define modes for different programming languages or frameworks such as "lisp mode" or "Ruby on Rails mode" or "PHP mode". These modes can directly modify even core behaviors of Emacs, automatically format or colorize text and add standard template or "boilerplate" text such as function declarations and closures. 

Programmers find Emacs to be far more customizable to their particular requirements than Vim. Yet some programmers may find Vim to ultimately be better suited to their programming environment due to its equally customizable and fully modal operation. 

Emacs can be extended in elisp, while Vim has its own internal scripting language and supports the use of other [programming languages](https://www.diffen.com/difference/Category:Programming_Languages) for plugin development.

While Emacs can be extended in elisp, Vim has its own internal scripting language and supports the use of other [programming languages](https://www.diffen.com/difference/Category:Programming_Languages) for plugin development can also be extended on the fly by using the command mode. The command mode allows configuration options to be set, functions to be defined, and macros to be made. Configuration files for Vim are just commands that can be input through the command mode.

6. Graphical User Interface (GUI)

Both Vim and Emacs have graphical user interfaces. Virtually all menu items on the graphical interface for both editors are simply ways to handle a shortcut command or quick configuration. The GUIs for the editors do not provide virtually any additional functions beyond those available in the CLI (command-line interface)

Emacs uses XDisplay or gtk2 for its GUI. Vim can use many other GUI libraries, such as gtk, [gnome](https://www.diffen.com/difference/GNOME_vs_KDE), gnome2, motif, athena, and neXtaw, in addition to gtk2.

## Summary

1. Vi is lighter and faster than Emacs.
2. Emacs is more customizable than Vi.
3. Emacs can emulate Vi but not the other way around.
4. Emacs later developed a GUI while Vi did not.
5. Emacs continued developing while Vi was succeeded by its variants.

## Do we still have a war or a clear winner?

In 2020, Jake King the CEO of [CMD](https://cmd.com/) decided to settle a long-time debate with his CTO Mike Sample, about which of the [two editors is more popular in the Twitter tech space](https://twitter.com/JakeKing/status/1245137819787382784?s=20).

{% embed https://twitter.com/JakeKing/status/1245137819787382784?s=20 %}.

You should want to make some vim friends right now.

## Further Readings

- [Why You Should Use Emacs](https://batsov.com/articles/2011/11/19/why-emacs/)
- [Emacs Editor Tutorial – An Absolute Beginners Reference](https://www.linuxfordevices.com/tutorials/linux/emacs-editor-tutorial)
- [Vim Tutorial – All You Need, To Get Started with VIM](https://www.linuxfordevices.com/tutorials/linux/vim-tutorial)
- [VIM Plug – The easy way to install plugins in VIM](https://www.linuxfordevices.com/tutorials/linux/vim-plug-install-plugins)
- [Vim Games - Interesting Vim puzzles](http://www.vimgolf.com/)