LinuxCommandLibrary

emacs

Edit text files

TLDR

Start Emacs and open a file

$ emacs [path/to/file]
copy

Open a file at a specified line number
$ emacs +[line_number] [path/to/file]
copy

Run an Emacs Lisp file as a script
$ emacs --script [path/to/file.el]
copy

Start Emacs in console mode (without an X window)
$ emacs [[-nw|--no-window-system]]
copy

Start an Emacs server in the background (accessible via emacsclient)
$ emacs --daemon
copy

Stop a running Emacs server and all its instances, asking for confirmation on unsaved files
$ emacsclient --eval '(save-buffers-kill-emacs)'
copy

Save a file in Emacs
$ <Ctrl x><Ctrl s>
copy

Quit Emacs
$ <Ctrl x><Ctrl c>
copy

SYNOPSIS

emacs [options] [file ...]

PARAMETERS

-nw
    Run Emacs in a text-only mode, without a graphical display.

-q
    Start Emacs without loading an initialization file (.emacs or init.el).

+[line]
    Open the file at the specified line number.

-daemon
    Start Emacs as a background daemon.

--version
    Display the version number.

--help
    Display help information.

-l file
    Load the lisp file at startup.

--eval expression
    Evaluate the Lisp expression.

DESCRIPTION

Emacs is a powerful, customizable text editor available on Unix-like systems. It's more than just an editor; it's a highly extensible environment. Users can tailor Emacs to their specific needs using Emacs Lisp, a powerful programming language.
Emacs offers a wide range of features, including syntax highlighting, auto-completion, extensive customization through its .emacs or init.el file, and integration with other tools and programming languages. It can be used for coding, writing documents, managing files, reading email, and even running interactive shells.
It's known for its steep learning curve but offers immense productivity gains once mastered. The editor's core is relatively small, but its functionality is extended through numerous packages and libraries. Emacs uses a buffer-based approach to editing, where each file is loaded into a buffer for modification. It's highly portable and available on a wide range of platforms. Many users rely on Emacs as their primary working environment, customizing it to fit their needs and workflows.

CAVEATS

Emacs can be resource-intensive, especially with many extensions loaded. The default keybindings are sometimes considered non-intuitive by new users. Mastering Emacs Lisp is essential for extensive customization. GUI version requires X server.

CUSTOMIZATION

Emacs is highly customizable through Emacs Lisp. Users can define their own functions, keybindings, and modes to tailor the editor to their specific needs. The `.emacs` or `init.el` file in the user's home directory is used to store these customizations.

BUFFERS AND WINDOWS

Emacs uses buffers to hold the content of files being edited. Multiple buffers can be open simultaneously, and Emacs can display multiple windows showing different buffers, or different parts of the same buffer.

HISTORY

Emacs was initially created in the mid-1970s by Richard Stallman. It was inspired by TECO macro sets. Over the years, it has undergone significant development and has been ported to numerous platforms. GNU Emacs is a free software version and is actively maintained.

SEE ALSO

vi(1), nano(1)

Copied to clipboard