Introduction
Emacs, originally named EMACS, is a text editor and one of the oldest text editor. EMACS is popular for its rich and powerful editing features. Emacs also offers powerful functionality with easy-to-install language support.
It is similar to vi’s and nano’s text editor but with more power and functions.
In this tutorial, we’ll learn how to install and use Emacs on Ubuntu 22.04 server.
Prerequisites
VPS with Ubuntu 22.04 Installed
Root access to the server via SSH
Installing Emacs on Ubuntu 22.04
First, update the system sudo apt update
Run the following command to install emacs on ubunut 22.04
sudo apt install emacs
Using Emacs on Ubuntu 22.04
Run the following command to use the emacs
emacs
After running the command, you will see the welcome message
Now, To create new file, press CTRL+X
,then CTRL+F
, then enter the new file name. After entering the file name, ENTER
. You will see blank screen
When Emacs edits an existing file on disk, a copy of that document is first loaded into memory and then displayed in the main editing window. This area in memory is called a buffer. As you work through the document, all the changes you make in the editing space are applied to the buffer, while the original file on disk remains unchanged. Occasionally, Emacs will auto-save in the background, but it’s only when you manually save the document that the changes are written to the disk. The same applies for a new file as well. All changes are made on the buffer until you save it. The main editing space in Emacs is your view to the buffer.
After the main buffer, a highlighted bar of text is displayed near the bottom of the screen. This is called the status bar or the mode line. The text revealed here depends on what mode Emacs is currently in. Among other things, the status bar includes:
- Name of the current file
- Current cursor location
- Current editing mode
- The status of the file (– for an unmodified file, ** for a file with un-saved changes and %% for read-only files)
Finally, a single line of space exists after the status bar where the screen ends. In this example, it’s showing the text “(New File)”. This area is called the mini buffer. Emacs is a command driven tool and the mini buffer is your main point of interaction. This is where Emacs prompts you for command inputs and reveals output.
The text-based version of Emacs treats windows differently from its GUI-based version. Unlike GUI-based applications, text-based Emacs windows don’t pop out as they can’t physically do so in a terminal or console session. When Emacs needs to start a new window its main buffer is split into two parts, like having two frames in a browser. The top half shows the main buffer and the bottom half displays the new content. An example of Emacs spawning a new window is when you are accessing its help files or tutorials.