# A short guide to emacs

> A short guide to the emacs editor on UNIX systems, covering how to open and edit a file, save with ctrl-x ctrl-w, and quit, plus the built-in tutorial.

Author: Flavio Copes | Published: 2020-11-03 | Canonical: https://flaviocopes.com/linux-command-emacs/

`emacs` is an awesome editor and it's historically regarded as _the_ editor for UNIX systems. Famously `vi` vs `emacs` flame wars and heated discussions caused many unproductive hours for developers around the world.

`emacs` is very powerful. Some people use it all day long as a kind of operating system (https://news.ycombinator.com/item?id=19127258). We'll just talk about the basics here.

You can open a new emacs session simply by invoking `emacs`:

![Emacs welcome screen showing the GNU Emacs startup interface with menu options and copyright information](https://flaviocopes.com/images/linux-command-emacs/Screenshot_2019-02-10_at_12.14.18.png)

> macOS users, stop a second now. If you are on Linux there are no problems, but macOS does not ship applications using GPLv3, and every built-in UNIX command that has been updated to GPLv3 has not been updated. While there is a little problem with the commands I listed up to now, in this case using an emacs version from 2007 is not exactly the same as using a version with 12 years of improvements and change. This is not a problem with Vim, which is up to date. To fix this, run `brew install emacs` and running `emacs` will use the new version from Homebrew (make sure you have [Homebrew](https://flaviocopes.com/homebrew/) installed)

You can also edit an existing file calling `emacs <filename>`:

![Emacs text editor with an open test.txt file containing sample text about the editor](https://flaviocopes.com/images/linux-command-emacs/Screenshot_2019-02-10_at_13.12.49.png)

You can start editing and once you are done, press `ctrl-x` followed by `ctrl-w`. You confirm the folder:

![Emacs save dialog showing Write file prompt with ~/test/ directory path in the minibuffer](https://flaviocopes.com/images/linux-command-emacs/Screenshot_2019-02-10_at_13.14.29.png)

and Emacs tell you the file exists, asking you if it should overwrite it:

![Emacs overwrite confirmation dialog asking File ~/test/test.txt exists; overwrite? with y or n options](https://flaviocopes.com/images/linux-command-emacs/Screenshot_2019-02-10_at_13.14.32.png)

Answer `y`, and you get a confirmation of success:

![Emacs showing successful file save confirmation with Wrote /Users/flaviocopes/test/test.txt message](https://flaviocopes.com/images/linux-command-emacs/Screenshot_2019-02-10_at_13.14.35.png)

You can exit Emacs pressing `ctrl-x` followed by `ctrl-c`.
Or `ctrl-x` followed by `c` (keep `ctrl` pressed).

There is a lot to know about Emacs. More than I am able to write in this little introduction. I encourage you to open Emacs and press `ctrl-h` `r` to open the built-in manual and `ctrl-h` `t` to open the official tutorial.
