emacs for writers: a few tips

I use word processors like OpenOffice Word as others use page layout software: Only when I want certain control over the final product, want it fast, and don’t demand too much of the product. For regularly produced formatted text I use some version of LaTex, but most of the twentythousandzillion words I write a week go out as HTML via blogs. For all actual writing (lists, notes, text, stuff for blogs, stuff for print, outlines, etc) I use emacs as the starting point. Any good plain text editor would do, but I found that emacs can be made to do tricks that are worth the trouble to learn them.

And it is trouble. The first few times I tried to use emacs I gave up. What finally made it work for me was ignoring the navigation paradigm entirely, forcing emacs to act like gedit/notepad/other standard text editors (where Ctrl-V inserts stuff, for example). Forcing emacs to do things this way breaks some of its functionality, but that is only functionality used by programmers. For writing, emacs out of the box is almost a great idea. Get the right .emacs file and you’re there.

(The .emacs file is the configuration file for the program.)

Following are a few neat tricks you can do with emacs. And, only with emacs. I’ll post a few tricks now and then to keep you interested. But I warn you: emacs is not for everyone.

Alt-X ascii-display

Produces an ascii table in a new buffer with the character your cursor (‘point’) is on highlighted. As you move point around the table updates.


Alt-X all

This may seem a bit obscure to those not doing programming (if you program it makes total sense): After entering Alt-X all you enter a regular expression and hit enter. The regular expression is to match multiple lines in your document. For instance, if I have these lines:


and I enter


the regular expression will match any line with any number of characters preceding and following the letter ‘y’.

Then, a second window pops up with just those lines in it. You can edit them, and as you do so, the lines are updated in the original document.


Alt-X boxquote-region
| … is one of several boxquote related functions.
| The purpose is to provide boxquoteosity to your text.
| The text you are reading now is box quoted thusly.
| I doubt this works well with wrapped text so for actual writers …
| …. this will have limited functionality.


  1. #1 P Smith
    July 16, 2011

    I enjoyed and miss the EDT editor from VAX systems I used back in my college days. The automatic saving of journal files and previous versions was great for programming or any writing. It was easy to recover lost work or go back to a previous version that worked before an inept programmer (e.g. me) screwed up something.

    I’ve never used emacs or Linux so I don’t know if it does that (it wouldn’t surprise). It’s a feature sorely lacking from Lose32 systems.


  2. #2 Linux in Exile
    July 16, 2011

    I find a lot of use in M-x replace-regexp-region to do a regular expression replacement (think sed) over a defined region. Very nice. A programmer showed this to me once, and I love it. Not part of the standard emacs though, but it’s easy to grab and put in your ~/.emacs file.

  3. #3 Woof
    July 16, 2011

    EDT? PhtPhtPhtPhtPht!!!

    Back in the day I could do some wonderful things on a VAX using EVE/TPU. Wish I could find a Linux implementation…

  4. #4 fancyflyer
    July 16, 2011

    Crimson/Emerald editor is a fine (free) tool for programming and data manipulation. I like it a lot.

    Info here: http://forum.emeraldeditor.com/

  5. #5 Greg Laden
    July 16, 2011

    M-x replace-regexp-region:


  6. #6 Grant
    July 17, 2011

    If you’re using Mac OS X check out TextWangler, the free “lite” counterpart to BBEdit, which does grep-style matching, rectangular text selection, multiple file searching and whatnot too.

  7. #7 Grant
    July 17, 2011

    That’s TextWrangler, with two ‘r’s – typos…

  8. #8 MadScientist
    July 17, 2011

    Bah, any hardcore *NIX guy would use ‘ed’ or ‘edlin’.

    However, I’m lazy – I just use KDE’s ‘kate’ (though it seems to have been dropped/renamed/replaced in KDE4). Emacs had beaten vi long ago but I could never get my head around learning to use emacs properly.

    [OT] It’s always good to know there are still people who use TeX/LaTeX; you can always spot articles written with MSWord/Excel because they look like some shit an 8-year-old would make up. You’d think people would at least learn to use Lyx to do their WYSIWYG writing and if they wanted to pay for graphing software they could get something half-decent like ‘Origin’.

  9. #9 Mirar
    July 17, 2011

    Emacs user since 20 years here (and programmer, so I don’t count) – just wanted to mention you also have C-U (ctrl-U) to alter many of the functions. The normal meaning is “4 of the next command”, so ctrl-u ctrl-u x will give you 16 (4 times 4) x in a row. But it also changes functions, so C-U M-% (ctrl-u alt-%) will change the normal query-replace to query-replace-word. C-U C-S will change the normal I-search to regexp-I-search.

    Also: there’s a M-x query-replace-regexp already in the standard emacs.

    (And I think the most useful feature of emacs is probably emacs macros – C-X ( etc. It’s really easy to do formatting or handling of a lot of data at once using those, especially in combination with I-search.)

    (NB: There’s a few different versions of emacs out there. These work in my version – gnu emacs 23.)

  10. #10 bibliovore
    July 17, 2011

    I like Lyx.

  11. #11 bjacobson
    July 17, 2011

    ascii-display is neat but not part of standard distro. I downloaded from http://www.emacswiki.org/emacs/download/ascii.el, added “(require ‘ascii)” to .emacs, and turned it on with “M-x ascii-on”.

    Related and useful is “C-u C-x =” which displays profuse information about the character at point.

  12. #12 Greg Laden
    July 17, 2011

    bjacobson: Damn, I forgot to mention the important part: These tricks come with “emacs goodies” … however, version 23 has those built in as far as I know, but yes, they are not automatically there in all versions.

  13. #13 ruben_r
    July 17, 2011

    Currently writing a dissertation, I actually started with emacs on org-mode. It is very, very good, and I recommend it to everyone with sufficient technical expertise (i.e. who won’t call me in the middle of the night asking how to insert an image…). However, since *some people* simply must have word files to insert comments, track changes and other such wimpiness, I eventually found myself mounting everything in bits on Word… Sigh… At least I expect to do the final typography in Lyx (which is also VERY, VERY GOOD)

  14. Ruben: Here’s a hint for when you are in charge of students. Text files can be usefully edited with a word processor. Open the text file with the word processor, turn on track changes, and edit. Then save-as or print-as the document in PDF format and give that back to the person doing the edits.

    This assumes “accept changes” is not a desired option. This simulates hand editing of a printed manuscript. If that is desired, this is the way to go.

  15. #15 ruben_r
    July 18, 2011

    Simple and elegant – certainly much simpler than making everyone use git (evil laugh). Thanks! For some reason I probably wouldn’t have thought about it in a million years! Except now I won’t have any reason to make people use git…

  16. #16 r
    July 18, 2011

    To avoid using a word processor, tried LyX, but became curious about the underlying LaTeX and so ended up using Jedit as a text editor.

  17. #17 Greg Laden
    July 18, 2011

    Ruben_r: Still, there will be ways to make people use git.

    r: Like that movie where the guy goes into the isolation tank and turns into an australopithecine and starts eating antelopes at the Frankel Park Zoo.

  18. #18 phayes
    July 18, 2011

    Why (defun replace-regexp-region … ) ?

    ‘C-h f replace-regexp’ says:

    “In Transient Mark mode, if the mark is active, operate on the contents of the region. Otherwise, operate from point to the end of the buffer.”

    The ability to use arbitrary lisp expressions for the replacement is fairly new in replace-regexp but I’d be surprised if that is.

  19. #19 Warren
    July 18, 2011

    TextWrangler is pretty good on OSX, yes. It’s got some robust compare functions, and is suitable for a lot of different environments.

    However, if you’re a writer and using OSX, it’s worth looking at Scrivener. Far too many useful functions and abilities for me to enumerate in this space.

  20. #20 Greg Laden
    July 18, 2011

    emacs works of OSX,of course.

  21. #21 rodrigo
    July 20, 2011

    boxquote requires an additional package


  22. #22 Graham Fawcett
    July 20, 2011

    Re: org-mode and having to create Word files: The latest version of Org has an “export to ODT” (OpenOffice) command, so it’s very easy to turn an org file into a Word document, for passing to colleagues who are PDF challenged. 🙂

  23. #23 Greg Laden
    July 20, 2011

    Rodrigo, not in the nightly build, apparently. I’ve never installed it but somehow it is there!

    Graham, though that feels dirty, I suppose it coudl be useful now and then!

  24. #24 prakash
    July 20, 2011

    BoxQuote is also part of emacs-goodies-el package (available on Debian or Ubuntu based systems).

  25. #25 Jason
    March 30, 2013

    I use AUCteX mode under Emacs to write my work in LaTeX, and Git for revision control.
    For those using Debian or Linux distributions derived from it, there are packages for Emacs, TeXLive, AUCTeX and Git, making installation easy.