21

I've used Emacs quite a bit, and I'm comfortable with the most basic commands/shortcuts, but I know Emacs has a lot more to offer than what I'm using. What are some of the lesser known features of emacs that can help me become a more productive programmer?

5
  • 9
    @Whoever voted to close: this is definitely not off topic... Sep 20, 2010 at 21:26
  • 1
    If this is off topic, I suppose the main purpose of this site would be for "tell me your favorite story" type questions.
    – MIA
    Sep 21, 2010 at 3:26
  • 2
    I don't see how this can be considered off-topic. If I asked this at Stack Overflow, it would probably be closed there as subjective. So if This doesn't fit at either site, where I am supposed to ask such a question?
    – GSto
    Sep 21, 2010 at 15:04
  • Productive programmer eh.. Sep 24, 2010 at 5:43
  • 2
    I'm voting to close this question as off-topic because it is asking about a software tool. However, it is both too broad and too old to migrate to Stack Overflow.
    – user22815
    Sep 23, 2015 at 0:33

8 Answers 8

18

Learn elisp.

  1. It allows you to program any shortcut you can think of. Any time you find yourself performing a multi-step process for something useful, you make a function out of it and bind it to a hotkey combo.

  2. It lets you experiment with functional programming - learning a new paradigm is a good way to expand your horizons.

1
  • Plus having some level of elisp fluency, will open a world of configurability. As soon as something annoys me I just try to fix it. Also yasnippet allows for programmable snippets which can save tons of typing (like alter the pattern inserted if you're in a header or implementation file, and about a million other tricks).
    – julien
    Sep 21, 2010 at 11:58
9

Check out this SO page, it has enough tips to boost your Emacs productivity by at least 2x:

http://stackoverflow.com/questions/60367?tab=votes&page=1

Also, you absolutely positively must use Org-mode if you're an Emacs user:

Org: Your Life in Plain Text

EDIT: Unfortunately, it seems the SO moderators not only closed the first question/link, but removed it as well, destroying knowledge and wisdom in the process. (Let's burn this book, we don't know where it belongs!) For now the only useful alternative link I've found is the HN thread discussing the SO thread:

The single most useful Emacs feature - Hacker News

4
  • SO link no longer works
    – funkybro
    Jul 27, 2012 at 8:46
  • Thanks for the heads-up, stuck an alternative in, it's not as good but has some tips.
    – limist
    Jul 27, 2012 at 14:09
  • 1
    You can still find the removed post in www.stackprinter.com see: stackprinter.com/…
    – barracel
    Jun 12, 2013 at 13:29
  • @barracel Thank you! A program/service has saved us from the foolishness of moderators.
    – limist
    Jun 21, 2013 at 6:42
4

Off the top of my head:

M-x compile     (now do C-x ` to cycle through errors)
M-x gdb
M-x grep-find
M-x find-tag    (aka M-.  and C-u M-. is "next" tag)
inferior-processes (if you use an interpreted language, 
                    you can eval directly from Emacs)
C-x v v         ([version control][1])

In general, the Compiling and Testing Programs chapter of the info pages is a good read.

4

The great Steve Yegge has written a very nice blog post 10 Specific Ways to Improve Your Productivity With Emacs. It includes tricks and habits like

  • keyboard configuration (Swap Caps-Lock and Control, rebinding M-X)
  • Deleting word with backspace (if you are fast enough typer, getting rid of the whole word and retyping it is more convenient than continuously hitting backspace until your typo is erased)
  • Navigation by incremental searching
  • Using temporary buffers and learn to navigate buffers efficiently
  • Getting rid of navigation by mouse, menus and other GUI things
  • Learning to use the help system
  • Learning the power of regular expressions

He also lists some useful emacs modes and mentions many other tricks that make people wait in anticipation for future updates to the blog post.

2

I know you specifically asked about methods and commands, but I would suggest the following all-around approach:

  1. Read a book on Emacs: there are several including the Emacs Manual, and Learning Gnu Emacs by Cameron Et al. I know "read the manual" sounds trite and condescending, but what I'm really saying is that every time I read the manual, I find out about something really cool that I didn't even think of. I always feel like I haven't spent enough time reading the manual.
  2. Get into the Emacs Community: Emacswiki is a great place to communicate with other Emacs users and find out about cool packages. Also joining help-gnu-emacs can be good, because people will ask for help on features that they're using, and by proxy you can find out about those features. I have found many interesting features by seeing someone asking for help and then reading about it in the manual.
  3. Learn some Lisp: When you can at least discuss Emacs Lisp, you'll be in a much better place to learn about new features.
  4. Use Emacs all the time. I use Emacs for everything except web browsing (which it you can also do), and I'm therefore always in an opportunity to learn how to do some new thing better with some feature provided by Emacs. I use Emacs for mail, scheduling and planning, version control, LaTeX documents, and programming. About all my time is spent in either Emacs or Firefox.
2

Custom workflow specific modifications

When I started doing Test Driven Development, I made an elisp function that would let me jump between the file with the unit-tests and the file with the production code in an easy fashion.

I also started using yasnippets for a few key language constructs, reducing the time it takes me to write the thing I write hundreds of times every day.

Last, but not least; I created luddite-mode, it simply turns off the menu/tool bars, fringes and scrollbars, forcing me to use keyboard shortcuts as much as possible.

0

Two commands I tend to use every now and then are string-rectangle and kill-rectangle. The former allows you to insert repeated text in a particular column over several rows; the latter does the opposite.

-1

I guess this is not the "lesser known" feature, but I tend to use Emacs for any repetitive text editing. Keyboard-macros rule! http://jamesthornton.com/emacs/node/emacs_487.html

Not the answer you're looking for? Browse other questions tagged or ask your own question.