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?
-
9@Whoever voted to close: this is definitely not off topic...– Chinmay KanchiSep 20, 2010 at 21:26
-
1If this is off topic, I suppose the main purpose of this site would be for "tell me your favorite story" type questions.– MIASep 21, 2010 at 3:26
-
2I 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?– GStoSep 21, 2010 at 15:04
-
Productive programmer eh..– Daniel LittleSep 24, 2010 at 5:43
-
2I'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.– user22815Sep 23, 2015 at 0:33
8 Answers
Learn elisp.
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.
It lets you experiment with functional programming - learning a new paradigm is a good way to expand your horizons.
-
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).– julienSep 21, 2010 at 11:58
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:
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:
-
-
Thanks for the heads-up, stuck an alternative in, it's not as good but has some tips.– limistJul 27, 2012 at 14:09
-
1You can still find the removed post in www.stackprinter.com see: stackprinter.com/…– barracelJun 12, 2013 at 13:29
-
@barracel Thank you! A program/service has saved us from the foolishness of moderators.– limistJun 21, 2013 at 6:42
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.
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.
I know you specifically asked about methods and commands, but I would suggest the following all-around approach:
- 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.
- 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.
- Learn some Lisp: When you can at least discuss Emacs Lisp, you'll be in a much better place to learn about new features.
- 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.
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.
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.
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