# 3 things you didn't know about Emacs and can use everywhere

I love a good text editor, and I was an aimless *sometimes-Vim sometimes-Kate sometimes-Gedit* until I fell solidly into Emacs thanks to a very wise boss who wanted to standardize tools within his team.
I didn't intend to become a user of Emacs exclusively, but every time I used a different editor for whatever reason, I found myself missing a feature of Emacs.
That's how text editors get you, though: you develop a subtle familiarity with an editor such that the "work" of translating thought, whether it's a network design idea, a specific configuration, or a Bash script, into text feels so natural that sometimes you have to type your thoughts just to make sense of them.

At some point, I accepted that I was an Emacs user, but I like a diverse toolset, I like alternatives and options.
That's one reason I use open source!
Emacs has a few key features that I consider essential, not necessarily in implementation but in concept.
Here are five features of a great editor I learned from Emacs, and strive to implement, one way or another, in any text editor I use.

## 1. Plugins and package management

Emacs has lots of plugins, and it's hard to imagine using a text editor that doesn't have user-contributed extensions.
In simpler times, it used to be that you could download an elisp file (or copy and paste it from the Internet) and stash it away in your `.emacs.d` folder for years, but development tends to be pretty fast-paced these days, and so Emacs also has a `package` command that lets you browse, install, and update plugins from within Emacs.

Not all text editors have plugins, and not all of them need plugins.
Sometimes the only feature you want in a text editor is simplicity.
However, for the text editor you use for hours at a time, plugins add important customizations and optimizations.

### Apply it to other editors

Text editors like [Atom](https://opensource.com/article/20/12/atom) and [VS Code](https://developers.redhat.com/products/vscode-extensions/overview) integrate package management in a similar way as Emacs does.
There's a dedicated interface for package browsing and maintenance.

![Atom packages](atom-packages.jpg)

As of version 8, [Vim](https://opensource.com/article/20/2/how-install-vim-plugins) has an official plugin structure based around the `~/.vim/pack/vendor/start` directory.
Install plugins there, and they're easy to find, maintain, and use.

Some editors don't have plugins, and that can be considered a feature.
Heck, neither Emacs or Vim had packages when they were starting out, either.
But most great editors have rich configuration options, and config hacks are essentially what most plugins start out as.
When using a simple editor, I tend to manage my config files so I can optimize the way I work, and replicate that experience in that editor regardless of what machine I'm using it on.

## 2. Integration

A good text editor, in my opinion, ought to feel less like an application and more like a part of your OS.
I want my editor to be fully aware that it's running on Linux, I want it to take me $HOME rather than to whatever it thinks is equivalent to My Documents, I want it to know that I'm in a Git repository and what branch I've checked out, I want it to not only invoke shell commands but the whole shell itself.
On Emacs, I can open an elisp shell with `M-x shell` or any terminal with `M-x term`, I can split screens with `M-x 2` and `M-x 3`, I see everything in its Git context, I can interact with my file system with `dired`, and so on.
There's very little separation between Emacs and everything else I do, and indeed there's rarely a reason for me to leave Emacs when I do need to run a quick command on localhost, or even take a quick glance at an email or even a PDF.

### Apply it to other editors

Many editors have similar integration features as Emacs.
There are features and extensions for Vim, Atom, VS Code, Kate, and many others that make the editor fit neatly into the rest of your system.
The trick is to take advantage of them.

It took me years to understand that Emmacs had a file manager built into it.
The muscle memory to **Alt-Tab** out my desktop was strong, but eventually the workload involved in leaving Emacs became too costly and I finally found myself defaulting to `dired`.
My hands never left my keyboard, I discovered new keyboard shortcuts (turns out that just **+** to add a directory is a lot quicker and easier to remember than `dired-directory-create`), and my workflow was permanently simplified.
No matter what editor you're using, find *that* shortcut.
Find the small integrations offered by your editor and put them to good use.
The features don't add anything to your life if you ignore them, so make them work for you.

## 3. Tramp mode and remote editing

The `tramp` command within Emacs enables you to edit a file on a remote system.

```
C-x C-f /ssh:[email protected]:~/example.txt
```

In terms of your experience, there's almost no separation between localhost and remote host.
It's a subtle and nearly transparent way to edit files without leaving Emacs or your favourite computer.

### Apply it to other editors

If your editor doesn't have a remote editing feature, your desktop might.
I don't use Emacs for *literally* everything, so I really appreciate GNOME's **Other Locations** feature.
To use it, open **Files** on GNOME and click **Other Locations** in the left panel.
Type in the protocol you want to use (such as `ssh:`, your username and destination host name in the **Connect to Server** text field at the bottom of the window, and click **Connect**.

![Believe it or not, those files aren't on my computer](gnome-other-locations.png)

It's an embarrassingly simple way to, more or less, corral lots of different systems into an apparently single filesystem.

## 4. Syntax and linters

I once wrote an article called [10 YAML tips for people who hate YAML](https://www.redhat.com/sysadmin/yaml-tips) and the zeroeth tip on the list was *make your editor do the work*.

![Make your editor do the work](https://www.redhat.com/sysadmin/sites/default/files/inline-images/emacs.jpg)

My point then, as now, is that a great editor ought to help you.
While Emacs (no, not even `M-x doctor`) can't tell me how to best write my next Ansible play, it *can* tell me that I've tried to [put a sequence where a mapping should go](https://www.redhat.com/sysadmin/yaml-beginners) in YAML, or that I've not indented my Python code, or that I've forgotten to close an XML tag.

Emacs has "modes", many of which are essentially plugins to help you follow some predefined structure.
There's `yaml-mode` and `nxml-mode` and `markdown-mode`, a mode for Python, Perl, Bash, Makefiles and many many more.

### Apply it to other editors

A great text editor probably has at least syntax highlighting.
Use it.
If your editor has an integrated linter, activate it.
I don't rely on my editor to ensure my configurations or code is valid, but I do allow it to point out obvious mistakes to me.

If your editor of choice doesn't have these features, then you should at least implement a reliable check after you've saved your work.
This takes discipline (or just a Git hook, if you're lucky) but it's better than discovering the error in production.

## 5. Keyboard shortcuts

I'll admit it, the real reason I use Emacs is because I'm used to the key bindings.
If I open an application that doesn't let me **Alt+B** or **Alt+F** to go back and forward a word, or **Alt+D** to delete a word, or **Ctrl+X I** to insert a file at my cursor position, I feel like I'm plodding along with stone-age tools (who uses Arrow keys or a mouse any more?).

### Apply it to other editors

There's no accounting for taste, and Emacs key bindings are admittedly an acquired one.
I remember finding Emacs shortcuts clunky and cumbersome compared to Vim, and in fact I used Emacs exclusively as a GUI client for years, defaulting to Vim for edits in a terminal.
Eventually, though, the key bindings started to take hold, and it's hard to walk away from them now.

Learning key bindings can be real work.
It takes you more time to look up a key binding you don't know than it takes you to just find the function in a menu you remember.
[Download a cheat sheet](https://opensource.com/downloads/emacs-cheat-sheet) for your editor of choice, or make one on a pad of paper as you go.
Invest the time in learning shortcuts now, and it'll pay dividends for years to come.

## Love your editor

Here's a bonus tip that Emacs taught me: you should really love your text editor.
Some people have an indifference to tooling, a "whatever works" attitude that admittedly makes for less friction but, then again, can lead to a life devoid of passion.
I'm not in computing to engage in flame wars like those you hear about in legends of old, but I do love computing.
I have requirements that aren't dogmatic, but that I do recognize as principles that lead to happiness in the long term.
One of them is to use open source, partly because I've been burned too often by non-open platforms and tools.
Another is to fall in love with my text editor.
If you're like me, you use a text editor almost all day, every day.
You should be excited to open your text editor, you should feel forlorn when you don't have access to that text editor, you should enjoy your time with your text editor.
If that text editor is Emacs, that's great.
If it's Vim or Nano or Atom or Kate or something else entirely, that's great too.
Get to know your text editor, and let it make your job easier and your life better.