Why do I use Emacs

About a year ago, when we were having knowledge transfer about one interesting Java component, the dude, who was showing me what the code was doing, suggested that I should use Eclipse instead of Emacs, because it is so much better editor. I can argue with people who claim that Vim is better than Emacs, but I just kept mouth shut this time.

My first contact with Emacs was in University, but I didn’t immediately see the power of Emacs. I got a job as a Windows programmer, and I started using Visual Studio like every Windows programmer. However, I was surrounded by these UNIX gurus, and watching them do their work in Emacs and in a shell, I realized that I could be much more productive, if I learned to use those same tools.

Visual Studio wasn’t that bad. I liked intellisense, but simple text manipulation was not on the same level as it was in Emacs for those gurus. Other Windows developers where also moving towards Emacs and I decided that I will also do that. The first year was though. First I tried to make my Emacs a full-blown IDE with all different views, but at some point I ended up having two editor frames side by side without any extra stuff.

Slowly, but steadily, I started to learn new things about Emacs and then I realized that I will never stop learning new things about it. At the same time I was reading Pragmatic Programmer, which is one of the best books ever. In Pragmatic Programmer there is one advice called : “Use a Single Editor Well”. I decided I will try to learn Emacs as well as possible and forget all the other editors and IDEs, because life is too short to learn two editors well.

I started to pick up really cool stuff for my Emacs. iswitchb-mode was one of my early favorites. It makes switching between open buffers a breeze. I always get a warm feeling, when I see people using their editors or IDEs to switch between open files. A lot of mouse movement or typing is required to get the job done. I do the same thing in Emacs with only a few key presses.

I was kind of missing “go to declaration” from Visual Studio, but when I discovered tags or especially xgtags, my worries were gone and I could easily jump to definitions and declarations without having to move my hand from the keyboard.

I knew about keyboard macros and thought they were really cool, but when I realized what rectangle operations could do, I was blown away. Manipulating text on multiple lines is a feature that should be in every single editor. Most editors nowadays have it, but I never see anyone else using the feature, but then again, I am surrounded by Visual Studio, Eclipse and Vim guys.

I loved iswitchb-mode, but I needed something similar to open new files. Currently I am using file-cache to do this and it’s brilliant. Just like with iswitchb-mode, I can type any part of the file name and open the correct file with only a few key presses. I know that anything.el could do the job of both iswitchb-mode and file-cache, but when I tried it just didn’t seem as smooth as the tools I was already familiar with.

Unfortunately I have to do some C++ coding, and when I discovered flymake, I almost crapped my pants. Now I would never have to fix compiler errors after trying to compile the code. I would fix them on the fly while writing the code. I am, of course, writing this using Emacs and have turned on flyspell-mode, which does the same thing for English language. This feature is, of course, in all the modern word processors and browsers, but not in many editors.

One last feature I would like to mention is yank-pop. When you learn to use, you can pretty much cut any piece of code or text, without having to worry about overwriting the clipboard with something else. This is a really powerful feature and I don’t understand, why it is not everywhere.

Most of these features are available in other editors also, but like I said, Emacs was the editor I decided to learn and I am sticking with it. You can use whatever editor you want, but don’t tell me that editor X is better than Emacs, because it probably isn’t.

I always try to be more productive and the editor plays a big role in this. Fortunately, Emacs allows me to this as good as any other editor or probably even better. Learning to use Emacs is a life long project, but I knew that it was the right choice for me when I made the decision. You might not want to spend so much time with your editor, but when I have my own company, I don’t have to hire you either.

  • Share/Bookmark

19 Comments

  1. Emacs and vim are both very good. I started w/the former but ended up w/the latter, because I had a vim guru around from whom I was able to learn all kinds of great things.

    I’ve tried Visual Studio and I didn’t like it, but to be honest, I’m not sure if I gave it a decent chance. I’ve also tried Eclipse and I find it an utter mess. The way different components don’t work together in it is just stunning.

    I tried the QT IDE last year and I actually kind of liked it. However, I’m still using vim because it has become part of me and I don’t need to think about it at all when I’m working w/it. I prefer being able to concentrate on the issue that I’m solving instead of the tools I’m using to solve the problem w/.

  2. Evan M says:

    I used iswitchb for a long time, until a emacs wizard friend pointed out ido-mode. It is like iswitchb but generalized to opening files and other operations as well. Definitely check it out.

  3. anon says:

    ido or icicles can easily replace iswitchb/anything

    for the vi users: emacs has several vim(m) emulation modes to choose from you don’t have to start from zero to start using something better

    another great feature of emacs is communication, you can easily contact your coworkers using irc/msn messenger/jabber/gtalk/icq/email right from within emacs
    also with org mode you can ie quickly write documentation and export it to html/docbook/latex or manage you appointments/tasks/todo list

    and let’s all hail tramp that makes working with remote/encriptted/compressed/suid files feel straightforward

  4. Matt R says:

    I consider myself an accomplished Eclipse user (daily for the last 3 years) and a journeyman Emacs user (on and off for the last 10 years). My conclusion so far is that, for coding Java, Eclipse is far superior, but I’m interested in refining my views to see how other people go about things. I’d genuinely like to know what you’d do in Emacs instead of the following (or whether you simply feel you wouldn’t benefit from the feature, or would approach things differently):

    1) Search for usages of a method / field (Ctrl-Shift-G)
    2) Highlight usages of a method / variable within the editor
    3) Go to a class on the class path (type search, Ctrl-Shift-T)
    4) Go to a resource in the workspace (Ctrl-Shift-R)
    5) Refactorings: extract method, extract local variable, rename stuff, alter arguments in a method call, convert anonymous class to nested, convert nested to top level.
    6) Integrated debugger
    7) AST select (Alt-Shift-Up/Down to select Java expressions)
    8) Find implementors of a type or method (Ctrl-T)
    9) Automated source formatting
    10) Import statement management (I almost never touch the import block, it’s code folded by default, and things get added and removed automatically by the IDE).

    I’d also note that Eclipse also lets you switch between your open buffers with a fairly minimal set of key strokes, and that it supports basic rectangle text editing.

    “I decided I will try to learn Emacs as well as possible and forget all the other editors and IDEs, because life is too short to learn two editors well.”

    Perhaps life is too short to use the wrong tool for the job? Emacs is superb at text editing, and I use it regularly in my work — alongside Eclipse, which is superb at handling Java. I’d also use Emacs to code anything which didn’t have sufficiently great IDEs available (truth be told, that’s most languages other than Java and C#).

  5. For Vim users clamoring for “rectangle operations” there is a mode in vim which allows for parallel multi-line edits. If you hold down control while using visual mode, you can select a number of lines at a given position and edit all of the lines in tandem by launching into insert mode. It also works for other operations in vi besides mere insertion.

    The way I look at it, regular expressions and multi-line editing handles any text operations on your language that fall under the class of regular languages. For something context-free you can use text macros. I think this is the true zen of vi. In any case, the mantra of “use one editor and learn it well” is probably some of the best advice for aspiring hackers.

  6. Mads Ravn says:

    I really like this article, and it makes me think I could become a much better emacs user. I use a clean and simple emacs and I don’t know anything about any of the addons or “modes” – could you please specify what to get and where to get it?

  7. There is some kind of IntelliSense in emacs (as a separate package, named ECB). I wrote about that a while ago on my blog (I enjoy also pointing out how great do you feel when working with emacs :) If you want to have a read I leave you the link: http://www.mostlymaths.net/2009/10/gdb-cedet-ecb.html

    Ruben

  8. @Evan

    I remember trying ido-mode a few years ago, I don’t exactly remember, why I chose to use iswitchb, but I will probably check it out again.

    @Mads

    You should checkout http://www.emacswiki.org/ and try different things and select the best that work for you.

    @Ruben

    I tried out ECB a couple of years ago, and it didn’t work that well back then, but maybe I should give another try.

  9. Sampo says:

    Somehow I feel that many people who claim to have used emacs for X years haven’t really ever embraced it fully.. Try code for it a bit, not just copy&paste customize it from net. Matt R, ever tried JDEE? It does pretty much everything you listed there.

  10. @Sampo

    At least I admit that I haven’t even nearly touched the full potential of Emacs. There is always something you can learn from it. I have done my share of ELisp coding, but I don’t want to spend too much time on it, because there is no end to it :)

  11. Well, agreed. ECB isn’t as good as IntelliSense, and sadly, has a strange tendency to slowing my netbook to a halt. But it is a good way to go, and I hope that given time it will be as useful as that.

  12. wolverian says:

    JDEE doesn’t provide any refactorings, which makes it a no-go for Java coding for me. Same for Vim’s Java plugins, unfortunately. Netbeans has an ok Vi emulator plugin, though.

  13. Petri says:

    I’m so done with Visual Studio right now. I want to move my IDE to something else and I’ve been thinking of emacs, mostly because I could use the same editor for different languages as well. So I’m interested in learning emacs. I’m also working on multiple platforms (most of my coding is done on Windows side) so is emacs cross platform enough to be used in multiple platforms?

    And do you have any good articles or books that introduce emacs?

  14. @Petri

    Emacs is perfect to use on multiple platforms. I use it almost every day on Mac, Linux and Windows.

    Couple of good Emacs blogs:

    http://emacsblog.org/
    http://emacs.wordpress.com/

    And of course http://www.emacswiki.org/

    I haven’t read any Emacs books myself, but searching “GNU Emacs” from Amazon gives a pretty good list of books.

  15. era says:

    Emacs is self-documenting and comes with extensive, on-line documentation. The core manuals are available from the FSF as printed books as well but I’ve never seen or even heard of anyone who actually needed a paper copy.

    For starters, try C-h i m emacs — on a Debian system you will need to install the manuals separately because (incredibly) they are not compatible with the Debian license. While you are at it, also install the Emacs Lisp intro amd reference manuals.

    Of course, all of this is available on the web as well.

    http://www.gnu.org/software/emacs/manual/emacs.html
    http://www.gnu.org/software/emacs/emacs-lisp-intro/
    http://www.gnu.org/software/emacs/elisp/

    The one Emacs book I have read and recommend is Bob Glickstein’s Writing GNU Emacs Extensions (O’Reilly 1997), if you’re into learning elisp programming. For the more philosophically inclined there’s Craig Finseth’s book but I have still not read that in full. http://www.finseth.com/craft/

  16. Glenn says:

    @Matt R:

    Like you I use Emacs as well as Eclipse. I tend to prefer Emacs for
    its multiple language support, but agree that Eclipse has superior
    Java IDE functionality. I think that Emacs has superior text-editing
    functionality. Java IDE support in Emacs is provided mostly by the
    JDEE package (http://sourceforge.net/projects/jdee/). Unfortunately
    this project was moribund for several years, but with the release of
    2.4 is being reinvigorated. It’s worth reviewing again, especially
    when used in conjuction with the ECB (ecb.sourceforge.net/).

    1) Search for usages of a method / field (Ctrl-Shift-G)

    M-x jde-find. Do you mean the call tree? Try the jde-usages
    package at http://jde-usages.sourceforge.net/. The CVS version
    seems to be the one to use.

    2) Highlight usages of a method / variable within the editor

    C-s (incremental search) does this.

    3) Go to a class on the class path (type search, Ctrl-Shift-T)

    M-x jde-open-class-at-point, or M-x jde-find.

    4) Go to a resource in the workspace (Ctrl-Shift-R)

    I don’t know of an exact equivalent of this, which is handy for
    giant projects whose organization and naming is obscure. I tend to
    use UNIX/Cygwin “find” on the command line, and since I’m often
    using Emacs in server mode, I can open the file in the same Emacs
    instance. There may be (probably is) an Emacs way to do this that
    I don’t know about.

    5) Refactorings: extract method, extract local variable, rename stuff,
    alter arguments in a method call, convert anonymous class to
    nested, convert nested to top level.

    I don’t use this stuff much, except renaming. By the time I figure
    out the Eclipse wizard I can usually have these things done
    manually. I tend to use Eclipse for renaming as it gets some text
    instances, too. Also, Eclipse can change method signatures more
    easily. I’ve been known to use sed (with checksed/runsed) for
    global changes. JDEE has M-x jde-rename-class, and perhaps there
    is a way to do this with Emacs tags.

    6) Integrated debugger

    JDEE has at least one of these, although I prefer the glossier
    Eclipse one.

    7) AST select (Alt-Shift-Up/Down to select Java expressions)

    I don’t know what this is.

    8) Find implementors of a type or method (Ctrl-T)

    I’d probably use grep for this, or jde-find.

    9) Automated source formatting

    C-M-\

    10) Import statement management (I almost never touch the import
    block, it’s code folded by default, and things get added and
    removed automatically by the IDE).

    M-x jde-import-organize

    It would be fair to say if I’m working on other’s people code I tend
    to use Eclipse for the debugging/refactoring/renaming, and if it’s my
    own code I tend to use Emacs. Writing new code is much faster for me
    with Emacs. Eclipse is better for skipping around large projects.

    I should note that Eclipse plays along well with Emacs—I often have
    both open. Buffers must be refreshed, but its surprisingly workable.

    Cheers,
    Glenn

  17. Benoit says:

    This article made me smile because I went through the same exact stages:
    - used emacs at Uni but didn’t fully embrace it,
    - then got a job as a Windows programmer so used Visual Studio for years,
    - there was a fellow developer there who was an Emacs guru,
    - I decided to use it as I had to switch from Windows to MacOSX from time to time and didn’t like the idea of having two different IDEs to use (and I knew deep inside emacs was brilliant),
    - I had to re-learn most things in emacs the first months I used it, but being able to customize it and to use it on different platforms was so good I sticked to it.

    I’m really so happy to be able to customize it exactly as I want. I often add some new functions when I realize there are macro-able actions I do really often…
    Now I moved to another company and I’m on Linux all day, and the transition has been so easy because I just copied my .emacs here and I have the same exact “programming experience”. If I had used Visual Studio all the time, I would have become really good at it, but now I would have had to throw all that knowledge to the bin because it obviously doesn’t work on Linux… If I want to program at home, or if I have to work elsewhere, thanks to that I’ll still be in the same environment, and won’t have to learn a bunch of new tools/IDE…

    You’re so right in saying that it doesn’t matter (or make sense) to say “X is better than Y”, the only important thing is to find one that you like, then learn it and customize it to your needs, and then stick to it….

Trackbacks / Pingbacks

  1. uberVU - social comments
  2. Why Emacs (or Vim) « Ionrock Dot Org

Leave a Reply