Emacs is one of the most popular terminal-based text editors. Actually, it’s more than just a text editor but more on that later.
This quick tutorial aims to show a few ways you can install Emacs on Ubuntu-based distributions like Linux Mint, elementary OS, etc. I’ll also share how you can get a more recent version using a PPA.
Even as a text editor, it has a steep learning curve. Therefore I have included the essential keyboard shortcuts at the end of the tutorial.
First, let’s see how to get Emacs on Ubuntu.
Method 1: Install Emacs from the Ubuntu software center
You can get Emacs easily from the Ubuntu repositories. It is available in the universe repository which should already be enabled in most systems.
If you prefer the graphical way, you can search for it in the Software Center and install it in a couple of clicks.
When you search for it, you can choose between GUI and Terminal versions, or you get both.
Once you choose your desired version, give it a single click, and it will open a prompt with all the details about that software. Click on the install button, and it will start the installation process.
That’s it, you have successfully installed Emacs without involving any commands!
Method 2: Install Emacs using terminal
If you are using an Ubuntu server or prefer the terminal, you can do all the above stuff in the terminal with just few commands.
First, enable the universe repository (not always enabled on servers) and update the package cache.
sudo add-apt-repository universe
sudo apt update
Now, you can get the terminal version of Emacs using this command:
sudo apt install emacs
If you are using Ubuntu desktop version and want to get the graphical Emacs editor, you can use this command:
sudo apt install emacs-gtk
Now, let’s open emacs to verify that the installation was successful.
emacs -nw
While writing this, Apt contains GNU Emacs version 27.1. But what if you want the most recent version? Just follow the given steps:
Method 3: Install the most recent version of Emacs using a PPA
Important: This is not the stable version, and you may face crashes or glitches. If you are looking for something between the stable and bleeding edge, skip to the 3rd method (it also includes the way to install the most recent version through snaps).
To download the bleeding-edge version of Emacs, first, we have to add ubuntu-elisp PPA:
sudo apt-add-repository ppa:ubuntu-elisp/ppa
Now, update your repositories to get further into installation:
sudo apt update
To install the most recent version of Emacs, use the given command:
sudo apt-get install emacs-snapshot
Once you are done with the installation, you can open Emacs in the terminal by utilizing the given command:
emacs -nw
Now, you are running the most recent version of Emacs!
Method 4: Install Emacs using snap
This is the sweet spot between the most stable and bleeding edge, as Snap will get you Emacs 28.1 at the time of writing this article.
To install Emacs classic edition, use the given command:
sudo snap install emacs --classic
As I mentioned earlier, you can also get the bleeding-edge version of Emacs through snaps. You just have to follow the given command and that’s it:
sudo snap install emacs --edge --classic
Now that you have got Emacs on your system, let me share a few tips with you.
Tips for getting started with Emacs
I would like to share some useful tips to make your Emacs experience a bit smoother. So let’s start with getting an idea of basic GUI elements.
Buffer: It can be understood as a channel for communicating with Emacs and can be used for interacting with files, shell, etc.
Window: The window is used to view buffers.
Mini-buffer: A primary command line from where you’ll be applying keybindings to use Emacs.
Now, let’s have a look at some basic keybindings through which you can start using Emacs.
Keybindings to create, find, and save files:
Keybinding | Description |
Ctrl+x Ctrl+f | Allows you to search and open files. It will create a new file if the file already does not exist |
Ctrl+x Ctrl+s | Saves current buffer content to file |
Ctrl+x Ctrl+w | Writes changes to file |
Keybindings for basic navigation:
Keybinding | Description |
Ctrl+p | To move the cursor up |
Ctrl+n | To move the cursor down |
Ctrl+b | To move the cursor left |
Ctrl+f | To move the cursor right |
Ctrl+a | To move the cursor at the beginning of the line |
Ctrl+e | To move the cursor at the end of the line |
ESC+f | To move the cursor by one word forward |
ESC+b | To move the cursor by one word backward |
This was just the tip of the iceberg, the possibilities of what you can do with Emacs are endless (I mean it!).
But you are not limited to the use of GNU Emacs as there are various forks available such as remacs, DOOM Emacs, and more.
Wrapping up
Emacs is not something that you can grasp within a few days. As I mentioned earlier, it is an ecosystem itself having its own package manager, window manager, games, and a lot more.
Many new users struggle with it, but once you get a grip on it, nothing can beat Emacs in terms of productivity and efficiency.