Written Assignment - Unit 4
Written Assignment - Unit 4
able to navigate Emacs, make sense of its many keyboard shortcuts, and work with files in the
editor. Please note that this guide will not be covering installation of Emacs, though you can find
installation instructions for your operating system here. Though Emacs can also be run in a
terminal, this guide will focus on the graphical user interface (GUI) version.
This is what you might see on screen when you first start Emacs. The main window in
Emacs is called a frame, so we will be referring to it as such (Kenlon, 2020). When we refer to a
window in Emacs, we are talking about the smaller panes within the frame, so it’s important that
we make that distinction early to avoid confusion. If this seems nonsensical and contrary to how
we use modern computer terminology, keep in mind that Emacs was around long before we
agreed on what should be called a “window”. While there is only one window shown in the
screenshot above, you can have multiple windows in the frame displayed horizontally and
vertically. Displayed in each window is a buffer, which will contain contents of whatever file
you have open and will also be where you type commands. By default, Emacs will start with the
*GNU Emacs* buffer, which can point you to many helpful resources. There is also a minibuffer
at the bottom, where you will be able to see the commands you type in. Like most programs,
there is the familiar menu bar at the top. While it is perfectly fine to use the menu bar, know that
Emacs can be entirely navigated through keyboard shortcuts. Whatever can be done from the
menu can also be done from your keyboard. Notice that next to most menu options, you can also
see the corresponding keyboard shortcut. Beneath the menu is the toolbar, which changes based
Keyboard Shortcuts
As you can see in the screenshot of the menu above, keyboard shortcuts in Emacs either
start with C or M. However, these are not referring to the C and M keys on your keyboard; they
really mean Ctrl and Alt. For example, to perform the shortcut for Undo (C-x u) you first hold
the Ctrl key while hitting the X key (written as Ctrl+X), then hit the U key. To Copy (M-w), you
would hit Alt+W. Here are a few other useful commands for editing and navigating an open file:
You may have noticed some shortcuts listed above can also be accomplished with single
keys on your keyboard. This is not done just for the sake of being redundant; Emacs is designed
to be compatible with a wide range of systems, including those that may lack things like arrow
keys. Even if your keyboard has the arrow and page keys, you may still find these commands
useful. The M-a and M-e shortcuts are especially useful for reading sentence by sentence, and
they’re a great demonstration of how Emacs can recognize human language units such as words
and sentences. There are many more commands to learn beyond the ones listed above, but these
should be enough to move your cursor around the screen. The *GNU Emacs* buffer you see at
startup contains links to tutorials and references that will help you get acquainted with keyboard
shortcuts.
Buffers
Whenever you open a new file in Emacs, the file you just had open doesn’t close. If you
go to the Buffers menu in your menu bar, you can see a complete list of your open buffers. You
can also use the C-x C-b command to open a buffer that contains a list of all open buffers, as
shown below.
x C-f [filename] to open a text file and to create a new text file, depending on whether the
filename you type in exists or not. Let’s create a new text file, edit it, then save it.
After typing C-x C-f, you will notice down in the minibuffer that the command you
typed in turns into Find file: and auto-fills in the file path after it with whatever directory
you are currently working in. Since our example file text.txt does not exist yet, running this
Once we are done editing our text file, use the C-x C-s command to save our changes. If
you glance down at the minibuffer, you’ll see a message that tells you the changes were written.
If you try to close the buffer for your text using C-x k while it has unsaved changes,
you’ll see a prompt in the minibuffer asking if you would like save your changes.
Working with different file types
While Emacs is primarily a text editor, it can also open other types of files. First, let’s run
through a quick explanation of the different file types. We can categorize files into two different
types. Text files are just that, files made up of plain text. These files can be read by any text
editor and include things like .txt files, config files, source code for software, and other types of
data stored as plain text. The other type, binary files, encompasses basically everything else. This
includes images, video files, and just about any file type you can imagine. Let’s see what
Kenlon, S. (2020, March 10). Getting started with Emacs. Retrieved from Opensource.com:
https://opensource.com/article/20/3/getting-started-emacs