When it comes to editor, Emacs for sure is my editor of choice. It is an incredibly extensible & productive editor. It works
in most platforms, and very well on terminals. Unfortunately though, it’s also an editor that have the steepest
learning curve, it’s hard to explain, simply refer to the following images.
*Image ref from StackExchange
Scratching the surface
It’s definitely not a beginner editor of choice, given the learning curve. I have been using it for a few years, and I still think there’re still a lot more to explore. Basically, using it means you get to learn something new everyday. And once you get used to it, it can be a great tool that you can’t easily work without. Besides, elisp is an interesting language with great string manipulation ability. Extending the editor using the language is really a fun experience.
Temptations
There’re actually a lot of editors/IDE(s) getting into the market, and they are of really good quality & much simpler to start with, yet still sufficiently powerful. e.g. Textmate, Sublime Text etc. I was tempted a few times and switched, but eventually going back.
Why stick with Emacs?
- I prefer doing keystrokes than mouse clicks, as it’s faster. Besides, the mechanical keyboard is so wonderful to type with.
- Given a big screen, Emacs can be splitted whatever way you wish. Then you can have irc, files and project trees organized.
- With emacs server up & running, it’s so fast to launch.
- Customizable is the biggest wins, since you can almost replicate any feature from modern IDE that you need using elisp.
- Muscle memory developed. It takes time to get into speed, but once you are there, you will only get faster & faster.
- Available in most platforms. Terminal FTW.
- Able to work on remote file with ease. Without the need to mount or simulate remote file system, more importantly, you can even launch emacs directly on the server since it lives in the terminal.
Few Emacs tricks I like
- Narrowing (C-x n n) can help concentrate on a particular part of the source code, says, a function or sub-routine. A buffer will be spawned with only the selceted portion displayed where it can be edited without distraction, and changes or commands are only effective to the narrowed buffer.
- Split Screens (C-x 3, C-x 2) provides flexibility on organizing your emacs screen. e.g. Can put emails, irc, terms or text files at each of the four corners respectively, so everything are within eyeshot.
- Rectangle Edit (C-x r t) allows you to work on rectangular areas of the text within certain pair of columns. It’s extremely handy, when you are editing a list or doing some prefix or postfix stuff.
- Search Occur (C-o during isearch) shows a buffer with all the matched items listed with line numbers. Tapping the item, will navigate you to the corresponding line in the file which is great. It’s simply like a index buffer.
- Show Paren Mode (M-x show-paren-mode) highlights a parenthesis when your cursor is on the other. It gives quick visual indication on which context you are working in & whether a parenthesis is closed/paired or not. It’s particularly useful when you are inside a function with many levels (not a good practice tho).
My must have Emacs packages
- Projectile If you ever used Cmd-T in Textmate or Cmd-P in Sublime Text, then this is it. On top of that, projectile primarily focus on helping you to work with projects by providing many convenient functions, e.g. projectile-ack, projectile-recent. This mode is always on in my emacs config.
- ido-mode with flx-ido lets you do things with buffer & files interactively. It lives in the mini-buffer, and get triggered when you do (C-x b) ido-switch-buffer or (C-x C-f) ido-find-file. It aids you thru buffer/file name autocompletion and fast search on recent-visited directories.
- tramp-mode is a builtin package for editing remote files. It uses remote shell connection (e.g. telnet, ssh) to give you transparent access to files on remote server. It saves you time from mounting remote drive (sshfs) and you can still use your local emacs config.
- magit is the best git interface ever used. It gives you easy access to common git operation, and quick way to inspect commits or file changes in a buffer. This mode alone is already a good reason to keep using Emacs.
- yasnippet provides common snippets for various mode, so to save you from typing all those boilerplate code thus reducing keystrokes.
- color-theme colors your file buffer thru syntax highlighting. Not just being a eye candy, but it improves code readily. Colortheme Gallery shows the available theme included in the package, so you can quickly have a clue which suits best.
- ack-and-a-half is an interface for ack inside emacs. Ack is a powerful search tools like grep but better, it’s for programmer. With this package, ack can be integrated easily within emacs, and code search can now be a wonderful thing without worrying irrelevant result (e.g. svn, git directories) messing the output.
- flymake allows emacs to perform on-the-fly syntax check using external tools. With proper config, it can work like what modern IDE are doing for the source file - displaying errors & highlighting lines that are problematic.
Conclusion
Using Emacs can be tough at first, but it definitely worth the effort. Together with proper config & packages, it will make a different on your editing productivity. To know more about my emacs setup, you can go to my emacs repo.