EMACS Flashcards
To gain more knowledge in Emacs as an editor
What do you understand by Emacs
Emacs is a powerful and customizable text editor that has been around since the 1970s. Emacs is widely used by programmers, writers, and other users who need to edit plain text files efficiently.
Emacs is often described as a “self-documenting” editor because it includes a built-in help system that allows users to quickly learn its many features and commands. It also supports a wide range of programming languages and file formats, making it a popular choice among developers and system administrators.
One of the defining features of Emacs is its extensibility. It includes a powerful scripting language called Emacs Lisp that allows users to write their own custom functions and macros, making it possible to automate repetitive tasks and tailor the editor to their specific needs.
Who is Richard Stallman
The person that developed Emacs
How to open or create an emacs file
C-x C-f
How to save an emacs file
C-x C-s
What is a buffer and how to switch from one to the other
In Emacs, a buffer is a temporary workspace in memory that contains a text document, file, or other form of data that can be edited. Buffers can be thought of as virtual windows into the contents of files or data that are open in Emacs.
Switching between buffers is a fundamental operation in Emacs. Here are a few ways to switch between buffers:
Step 1: Use the keyboard shortcut C-x b (which means “Control-x b”) to open the switch-to-buffer command. This will allow you to type in the name of the buffer you want to switch to. If you press Tab after typing a few characters, Emacs will show you a list of matching buffer names that you can choose from.
Step 2: Use the keyboard shortcut C-x C-b to open the buffer list. This will display a list of all open buffers in the current Emacs session. You can navigate through the list using the arrow keys and press Enter to switch to the selected buffer.
Step 3: Use the keyboard shortcut C-x right arrow and C-x left arrow to switch between the previous and next buffer in the buffer history.
Step 4: Use the command ibuffer to open the buffer list in a more powerful and customizable way. This command allows you to filter and sort the list of open buffers based on various criteria such as buffer name, major mode, or file location. You can also mark multiple buffers for further operations such as closing or saving.
Note: These are just a few examples of the many ways to switch between buffers in Emacs. Emacs provides a vast array of commands and customization options for working with buffers, making it a powerful and flexible tool for editing text and data.
How to use the mark and the point to set the region
In Emacs, the mark and the point are used to set the region, which is a highlighted portion of text that can be operated on as a unit (e.g. cut, copy, or replace). The mark and the point can be set using keyboard commands, and they work together to define the beginning and end of the region.
Here’s how to use the mark and the point to set the region:
Move the point to the beginning of the region by pressing C-SPC (Control-space) or C-@ (Control-shift-2). This sets the mark to the current position of the point, which is initially located at the beginning of the region.
Move the point to the end of the region by using any of the standard movement commands (e.g. C-f to move forward by one character, C-n to move down one line, etc.). As you move the point, the region will be highlighted.
Once the point is at the end of the region, you can perform operations on the region using Emacs commands. For example, you can cut the region by pressing C-w (Control-w), or copy the region by pressing M-w (Meta-w). To replace the region with new text, simply type the replacement text and it will overwrite the highlighted region.
To clear the region and remove the highlighting, you can press C-g (Control-g) to cancel the operation, or press C-SPC or C-@ again to move the mark to a different position and clear the highlighting.
These are just a few examples of how to use the mark and the point to set the region in Emacs. The mark and the point are powerful tools that allow you to work with text in a precise and flexible way, and there are many other commands and customization options available for working with them in Emacs.
How to cut and paste lines and regions
To Cut = C-w
To Paste = C-y
Note that C stands for Control
How to search forward and backward
Forward search, C-s
Backward search, C-r
How to invoke commands by name
In Emacs, you can invoke commands by name using the M-x (Meta-x) command. This command allows you to type the name of a command and execute it directly, without using a keyboard shortcut or menu.
Here’s how to invoke commands by name:
Press M-x (Meta-x) to open the execute-extended-command prompt. This will display a message at the bottom of the Emacs window asking you to type a command name.
Type the name of the command you want to execute. As you type, Emacs will display a list of matching commands that you can choose from. You can use the arrow keys to navigate through the list and press Enter to select the command you want.
Once you have selected a command, Emacs will execute it and display any relevant prompts or messages. For example, if you execute the find-file command, Emacs will prompt you to enter a file name or path to open.
You can also use M-x to execute commands with arguments or options. After you type the name of the command, you can enter any necessary arguments or options in the same way you would when invoking the command with a keyboard shortcut or menu.
For example, to execute the replace-string command and replace all occurrences of “foo” with “bar”, you can type M-x replace-string, enter “foo” when prompted for the string to replace, enter “bar” when prompted for the replacement string, and then press Enter to execute the command.
Using M-x to invoke commands by name can be a powerful and convenient way to access Emacs functionality, especially for commands that don’t have a dedicated keyboard shortcut or menu item.
How to undo
Undo, C-x u
How to cancel half-entered commands
If lost or made a mistake, C-g
How to quit Emacs
To exit/quit, C-x C-c
In Emacs’ documentation, what does M in a shortcut command stand for?
Alt
Meta
You can only have one buffer open in Emacs at a time. (True/False)
False
In Emacs’ documentation, what does C in a shortcut command stand for?
Ctrl