Great Emacs Features

Some useful features of Emacs that are around, but sometimes take years to discover.

I would prefer that this page not turn into an emacs vs X war, but merely as a useful page for people who already use and prefer to use emacs, but may be missing some useful functionality. Not everyone likes to read the 400-page manual. So drop in on GreatVimFeatures if you feel provoked!

See also GreatEmacsLispSnippets


How about:


The feature that convinced me to learn Emacs was ^x^m, which runs make, and then the ability to look at all the errors one at a time with ^x^e. I used that feature heavily for years. However, I haven't used C or make for a long time, but I still sometimes use Emacs.

The main thing I like about it now is that I can run it on a dozen different kinds of machines, and I've been using it for nearly 20 years without having to retrain my fingers. I know other editors have advantages, but not worth the time to retrain my fingers.

-- RalphJohnson


What is outline-mode? It's like this:

image never seems to work.

You can specify a RegularExpression that matches outline headings (here I'm using " *>"), and then headings are highlighted, can be automatically folded up (shown as ...), etcetera. Importantly, this is just a plain text buffer displayed in an unusual way: you can ask emacs to display for example LaTeX source in the same way.


Still looking for a (C++) editor that can

I thought I saw that in VS.NET for C# (but, thank God, I won't be doing C# any time soon.) Can Emacs do that? -- AndrewQueisser

VS.NET's C++ editor can.

Not to my knowledge, i.e. without programming. But if you use a sane indentation convention, the following is often close enough:

C-u 2 C-x $
This hides all lines which don't have anything in column zero or one, which normally has the desired effect of giving you a nice overview of the file. Of course, it's more useful in lisp modes and C++... but you get the idea. C-x $ again to turn it off. The name of the command is set-selective-display.

For python code, C-u 6 C-x $ is a good way to fold method bodies while still being able to read class names and method signatures.

There's something called outl-mouse that works with outl-minor-mode. It provides little arrows that you can click on to hide/expand some section of code.

Folding and narrowing will do this for you - check out this at the EmacsWiki: http://www.emacswiki.org/cgi-bin/wiki.pl?CategoryOutline -- ChanningWalton

Have you looked at speedbar (http://cedet.sourceforge.net/speedbar.shtml)? -- DimiterKurtev

From the above link:

Speedbar is an EmacsLisp program which allows you to create a special skinny frame with a specialized directory listing in it. This listing will have both directories and filtered files in it. You can then load files into your emacs frame, or expand the files to display all the tags that are in them and jump to those tags.


How does a person load the new code for a mode and make the mode available for use?

Say you've grabbed WikiMode, and you've put the file in your home directory:

To load the code manually, just for this session, type:

  M-x load-file RETURN ~/emacs-wiki.el
If you always want to do it, put the equivalent line in your .emacs file:
 (load-file "~/emacs-wiki.el")
You can always see the EmacsLisp equivalent of the last thing you did by hitting "C-x ESC ESC". Then you can cut it and paste it wherever you need it.

There are lots of refinements (like auto-load to load things only when you first use them), but that's the basic mechanism.


A useful project could be to outline many of the operations that can be performed in both Emacs and Vim and explain how to do each one in both editors.

Having used both, there are some things I know how to do in one but not the other. Yet, I always hear that anything you can do in one you can do in the other.

I doubt that the above is true. Unless I misunderstand the design of vim, there are many things you can do in emacs that you cannot do in vim (let alone vi). However, the issue is more about the things you want to do in your editor, and I expect that for many people this feature set is similar in both


For programmers working on MacOsx with the newest (December 2002) version of the developer tools, it's possible to use emacs as ProjectBuilder's text editor. BbEdit can also be used. This should please a lot of people who don't like PB's built-in editor... I find it just fine, myself, but I suppose different people need different things from an editor. -- JoeOsborn


Note that this page is a subset of http://purl.org/wiki/emacs/EmacsNiftyTricks. -- ShaeErisson et al


Ripped bleeding from GreatVimFeatures:

These days I use keyboard macros in Emacs, but the problem there is that you have to know before you do something the first time that you will want to do it again, and tell Emacs to start recording. In vi you don't need to know that in advance.

You have just realized, "Hey, that would make a pretty cool keyboard macro". Hit Control-X Control-K, and Emacs will prompt you for a "Keyboard macro to edit". Hit Control-H L. Emacs will present you with a macro editing window filled with your last 100 input keystrokes (the "lossage"). Edit to your heart's content, and hit Control-C Control-C to save.

The only drawback is that mouse actions are not supported, and Emacs will refuse to start the editor. Get around this by editing the "last keyboard macro" (Control-X Control-K Control-X E), viewing the lossage manually (Control-H L) and pasting the lossage into the editing buffer.

(Note: The command is kmacro-edit-lossage and it's on C-x C-k l here)


If there is a series of commands that you want to execute repeatedly and without bothering to remember C-x C-k commands, use <F3>/<F4>. Use <F3> commands... <F4> to push a new macro onto the macro ring, then <F4> to repeat the last created macro as many times as you wish. C-u # <F4> repeats the last macro that many times, and C-u <F4> repeats the second-to-last macro. (If you like, when you're done with a macro, you can delete it with C-x C-k C-d. See C-x C-k C-h for help.) For example, to replace the last 4 characters of the first word of the next 10 lines with "Foo", type <F3> M-m M-f C-u DEL F o o C-n <F4> C-u 9 <F4>.


Hey if you want to bring Emacs keybindings to all your Windows apps, check out the freeware XKeymacs (yes there's a "K" in there). Imagine having a kill ring in Notepad (yes it incredibly gives a kill ring to all your Windows apps). Or using Emacs keys in Mozilla. [Jon Aquino]

TextExtras? is a similar thing for OSX. It plugs into the Cocoa text system to give all kinds of neat features to any Cocoa edit area (completion, Emacs KeyBindings?, autoindent, piping to external commands) http://www.lorax.com/FreeStuff/TextExtras.html


CategoryEmacs


EditText of this page (last edited July 28, 2014) or FindPage with title or text search