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?
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.
Check out this SO page, it has enough tips to boost your Emacs productivity by at least 2x:
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:
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])
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.
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.
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