Overview
Emacs is a powerful tool for text editing, capable of performing various tasks such as programming, document writing, and email management. It is characterized by its high extensibility and customization capabilities, allowing for the addition of features through numerous modes and packages.
Key Features
- Highly extensible and customizable
- Functionality implemented via Emacs Lisp
- Support for both terminal and GUI environments
- Support for various programming languages and file formats (modes)
- Can be utilized as an Integrated Development Environment (IDE)
Key Options
Emacs provides various command-line options to control its startup behavior.
Opening Files and Modes
Information and Help
Generated command:
Try combining the commands.
Description:
`emacs` Executes the command.
Combine the above options to virtually execute commands with AI.
Usage Examples
Here are some basic examples of using Emacs.
Open a New or Existing File
emacs myfile.txt
Starts Emacs and opens the file 'myfile.txt'. If the file does not exist, it will be created.
Run Emacs in the Terminal
emacs -nw another_file.py
Runs Emacs in the current terminal, not in a GUI environment. This is useful when connected via SSH.
Run Emacs Without Initialization Files
emacs -q
Starts Emacs without loading custom configurations (init.el). This is useful when Emacs is not running properly due to configuration issues.
Execute an Emacs Lisp Function
emacs -f list-packages
Starts Emacs and executes the 'list-packages' function to display a list of installed packages.
Installation
Emacs may not be installed by default on most Linux distributions. You can install it using the following commands.
Debian/Ubuntu
sudo apt update
sudo apt install emacs
Installs Emacs using the APT package manager.
Fedora/CentOS/RHEL
sudo dnf install emacs
Installs Emacs using the DNF (or Yum) package manager.
Arch Linux
sudo pacman -S emacs
Installs Emacs using the Pacman package manager.
Tips & Notes
Emacs has a learning curve, but once mastered, it can become a very powerful productivity tool.
Basic Key Bindings
Emacs uses a unique key binding system. 'C-' refers to the Ctrl key, and 'M-' refers to the Alt (Meta) key.
- C-x C-s: Save file
- C-x C-f: Open file
- C-x C-c: Exit Emacs
- C-g: Cancel current command (very important!)
- M-x: Execute command (in the minibuffer)
Learning Emacs Lisp (Elisp)
The true power of Emacs is unleashed through Emacs Lisp. You can perfectly customize Emacs by writing your own functions or modifying existing packages.
Utilizing Package Managers
Emacs offers numerous extension packages through package repositories like MELPA. You can explore and install packages using the 'M-x list-packages' command.