I use Emacs. However, unlike some Emacs users, I don't treat it as a religion. In fact, I'd rather be using a more "modern" IDE; one that understands my code on a deeper level and provides things like refactoring tools, integrated debugging, and "view method implementation" that work reliably and don't require weeks of configuration effort to use. One that uses modern UI conventions instead of arcana from the 70s so that my friends who are not emacs-heads can quickly wrap their heads around what's going on on my screen, and perhaps dare to touch my keyboard.
However, even if one is keen to do it, switching away from Emacs is a big deal. I see lots of editors that advertise "emacs keybindings". While I appreciate the effort, these features always look like someone who has no idea how to use Emacs worked through some kind of quick cheat-sheet of features like "keybinding for Save", "keybinding for Save As", "keybinding for Close Window" and just added them one after another. Sometimes, with no regard for whether these keys conflict with other shortcuts! (I'm looking at you, gnome "key-theme".)
Do you think you can write an editor which can replace Emacs for me? Here are a few features, taken both from my years of customizing Emacs to meet my needs and some basic features in Emacs itself that non-natives never seem to understand.
I'm leaving out the extremely basic stuff like "syntax highlighting" and "automatic indentation" since most editors do OK on those fronts already. These are the things that I find have been subtle, in that they're broken almost everywhere outside of emacs.
Can you do what I mean when I press the "go" button?
When I edit code, I repeat these steps endlessly:
When I'm done, I push F5 and it immediately jumps my cursor to the error that i'm working on.
This works for me in Java, in C, and in Python. I've got a little bit of custom emacs-lisp code that I wrote to do each of them. I'm willing to write a little more. But, is it very easy in your editor to grab a global keybinding? To write a plugin in 4 or 5 lines of code that just formats a command-line string to run? To parse the output of a subprocess? To visit a file and line number without requiring further user interaction?
Now, let's say I've got the file "foo.c" open in several different branches of the same project, and I want to quickly alternate between them, display them side-by-side, etc. In Emacs, "C-x C-b" will bring up a list of every open file, and as I type its name, the list is reduced to only those who match what I've typed so far. So if, for example, I type "foo.c", I'll get all my "foo.c"s. I can cycle between them with C-s until I get the one that I want.
I don't want to hunt around and click on a tab-bar or hit "next next next next". I just want to type in a little bit of the file name and have the editor figure the rest out for itself.
Your editor probably can't run in a terminal. So you'd better give me a way to pair-program with people over the internet and a way to access the editor on my desktop machine when I'm away from home.
In Emacs, when I cut five or six different pieces of text, and I go to paste them, I can paste any of them. I don't have to carefully remember what's on my clipboard, because the last 60 or so things that I cut or copied are around in case I need any of them.
This is particularly helpful when, for example, inserting some import statements. I'm in the middle of a function in the middle of a big file. I want to use the Foo class, but it's not available yet. So, I jump to the beginning of the buffer, type "from baz.bar.foo import Foo" and then hit "C-u C-space" to jump back to the middle of that function I was working on. "C-x C-space" does something similar, but can even take me to different files.
* When I have a long documentation comment in ActionScript, JavaScript or
* Java, Emacs will helpfully wrap it like this. If I make changes in the
* middle and then re-wrap it, it stays wrapped and helpfully adjusts the
* placement of the asterisks along the left-hand side. Can your editor do
* this?
*/
# But when I have a comment in Python, it's formatted like this. I don't have
# to tell Emacs anything about the different comment styles.
-- For that matter, it can understand and properly format SQL comments too.
-- And C/C++, and Ruby, and PHP, and more.
"""
If I format code inside a docstring, it flows properly too. Granted, there are
a lot of bugs in this particular case in the stock Emacs, but since it works
everywhere else I have written some workarounds. (You could always work around
it by inserting some extra blank lines before wrapping, but that always
bothered me.) Can I customize how your flowing works if I don't like it?
"""
Last but not least...
For example, I have my own "snippets"-type module, "quick-hack mode", which does a ton of clever-clever things like inserting
I have a hotkey to turn this off in case other people find it annoying — and it's difficult to be ambivalent about this mode, you either love it or hate it: it's a very personal thing, and I don't expect your editor to support it directly. This mode was developed after years of observing my own peculiar tics while editing and crafting conveniences to support that and free me from distractions.
Since developing this kind of support code isn't my main interest, coding needs to be more than possible, it needs to be easy. I need interactive help and the ability to load a brief snippet of code into the editor without restarting it; a reasonable debugger so when it blows up in my face I can at least sort of tell why.
However, even if one is keen to do it, switching away from Emacs is a big deal. I see lots of editors that advertise "emacs keybindings". While I appreciate the effort, these features always look like someone who has no idea how to use Emacs worked through some kind of quick cheat-sheet of features like "keybinding for Save", "keybinding for Save As", "keybinding for Close Window" and just added them one after another. Sometimes, with no regard for whether these keys conflict with other shortcuts! (I'm looking at you, gnome "key-theme".)
Do you think you can write an editor which can replace Emacs for me? Here are a few features, taken both from my years of customizing Emacs to meet my needs and some basic features in Emacs itself that non-natives never seem to understand.
I'm leaving out the extremely basic stuff like "syntax highlighting" and "automatic indentation" since most editors do OK on those fronts already. These are the things that I find have been subtle, in that they're broken almost everywhere outside of emacs.
Can you do what I mean when I press the "go" button?
When I edit code, I repeat these steps endlessly:- Edit a test file.
- Run the tests.
- Edit an implementation file.
- Run the tests.
When I'm done, I push F5 and it immediately jumps my cursor to the error that i'm working on.
This works for me in Java, in C, and in Python. I've got a little bit of custom emacs-lisp code that I wrote to do each of them. I'm willing to write a little more. But, is it very easy in your editor to grab a global keybinding? To write a plugin in 4 or 5 lines of code that just formats a command-line string to run? To parse the output of a subprocess? To visit a file and line number without requiring further user interaction?
Can I reach the thing I need to work on fast?
Let's say I'm working on a file called "foo.c". I want to open "bar-baz-boz-qux.c" in the same directory. In Emacs, this is probably just "control-x control-f b <tab> <enter>" - maybe a few more letters if there are other "bar-" files. Do I need to hit more buttons than that in your editor? Do I need to reach for the mouse? Do I need to navigate the inefficient-even-from-the-keyboard GTK file dialog?Now, let's say I've got the file "foo.c" open in several different branches of the same project, and I want to quickly alternate between them, display them side-by-side, etc. In Emacs, "C-x C-b" will bring up a list of every open file, and as I type its name, the list is reduced to only those who match what I've typed so far. So if, for example, I type "foo.c", I'll get all my "foo.c"s. I can cycle between them with C-s until I get the one that I want.
I don't want to hunt around and click on a tab-bar or hit "next next next next". I just want to type in a little bit of the file name and have the editor figure the rest out for itself.
Can I use it on Mac, Linux, FreeBSD, Solaris, and Windows?
Emacs is extremely portable. Every operating system I want to work on (and many, many that I hope I never do) can run it. I don't want to invest the energy to learn a new editor if I can't use it everywhere.Can I use it remotely over the internet? Collaboratively?
You can cheat on this one: if you can run in a terminal (and under Screen), then you get both of these for free. Emacs cheats that way. But if you can't run in a terminal - no, I'm sorry, VNC is not an acceptable substitute. It doesn't perform adequately over the internet and it probably never will - as the internet gets faster, the average display gets bigger and has more colors on it.Your editor probably can't run in a terminal. So you'd better give me a way to pair-program with people over the internet and a way to access the editor on my desktop machine when I'm away from home.
Can I see whitespace?
I don't like to leave invisible droppings in files when I edit them. I'd like to be able to see trailing whitespace, highlight it, and eliminate it. I'd like to be able to tell if I have any tabs in my files (python does not like that very much).Do I need to carefully juggle my clipboard - or do you have a "kill ring"?
Normally, if you cut some text, then cut some other text, you lose the first text — unless you use "undo" or something like that and screw up your editing state.In Emacs, when I cut five or six different pieces of text, and I go to paste them, I can paste any of them. I don't have to carefully remember what's on my clipboard, because the last 60 or so things that I cut or copied are around in case I need any of them.
Do I need to carefully remember where I was and scroll around to get back there - or do you have a "mark ring"?
Emacs has what amounts to a "back button" for your text editor. If I edit something interesting, go to another window, go to another project, and then want to jump back a few steps, I can easily do that.This is particularly helpful when, for example, inserting some import statements. I'm in the middle of a function in the middle of a big file. I want to use the Foo class, but it's not available yet. So, I jump to the beginning of the buffer, type "from baz.bar.foo import Foo" and then hit "C-u C-space" to jump back to the middle of that function I was working on. "C-x C-space" does something similar, but can even take me to different files.
Can you do smart word-wrapping?
/*** When I have a long documentation comment in ActionScript, JavaScript or
* Java, Emacs will helpfully wrap it like this. If I make changes in the
* middle and then re-wrap it, it stays wrapped and helpfully adjusts the
* placement of the asterisks along the left-hand side. Can your editor do
* this?
*/
# But when I have a comment in Python, it's formatted like this. I don't have
# to tell Emacs anything about the different comment styles.
-- For that matter, it can understand and properly format SQL comments too.
-- And C/C++, and Ruby, and PHP, and more.
"""
If I format code inside a docstring, it flows properly too. Granted, there are
a lot of bugs in this particular case in the stock Emacs, but since it works
everywhere else I have written some workarounds. (You could always work around
it by inserting some extra blank lines before wrapping, but that always
bothered me.) Can I customize how your flowing works if I don't like it?
"""
Is there version-control integration?
If I'm editing a project that uses bzr, darcs, git, svn, hg, perforce, or cvs, I can get a nice "status" page as a jumping-off point in Emacs to show me which files are in version control and what files I've edited. I can update, commit, pull, push, and diff out without leaving the editor. Can your editor do that? And I don't just mean, can your editor do that for SVN. Does it support all of the systems I just named and a few others for good measure?Can I tell what I'm working on?
I don't like having to scroll around to figure out what function I'm in the middle of when I forget. I work on a lot of code, and I browse a lot of code, and sometimes if I'm in the middle of a 200-line-long function I can't see the class or the function name. Emacs has a feature called "which-func-mode" which allows me to glance at the bottom of the screen and instantly know what function I'm working on. Fancy, glowy sidebars with tree-views of my whole source file and inheritance hierarchy are great, but can I always see the name of the class and the method that I'm working on now? Even if there are so many other methods on that class that the fancy method list on the left has to scroll?Last but not least...
Can I code for it?
I'm a programmer and I need a programmer's editor. I don't want to write giant, heavyweight plugins; I want to be able to quickly toss off a snippet of code which modifies the editor. But, I'm not an IDE developer. I don't want to write a giant plugin; I want an editor which lets me organically grow my own modifications when I find myself doing some task frequently.For example, I have my own "snippets"-type module, "quick-hack mode", which does a ton of clever-clever things like inserting
def (self):when I type "def" inside of a "class" block. (of course the "def" is omitted otherwise).
"""
"""
I have a hotkey to turn this off in case other people find it annoying — and it's difficult to be ambivalent about this mode, you either love it or hate it: it's a very personal thing, and I don't expect your editor to support it directly. This mode was developed after years of observing my own peculiar tics while editing and crafting conveniences to support that and free me from distractions.
Since developing this kind of support code isn't my main interest, coding needs to be more than possible, it needs to be easy. I need interactive help and the ability to load a brief snippet of code into the editor without restarting it; a reasonable debugger so when it blows up in my face I can at least sort of tell why.
25 comments:
Nice summary of emacs' features! I guess the hardest part to reproduce will be the emacs keybindings. But if you kick the habit, many current IDEs already offer what you need, and much, much more. I made the transition from emacs to Netbeans when I was coding a lot of java. I never regretted it. Now that I do lots of python I was using emacs again, until Netbeans offered python support in its current version. Again, switching away from emacs was less painful than it seems. Did you try netbeans already?
Can you give some pointers or module name on where to learn more about the productive tricks in emacs? Especially concerning code browsing, this is a need easily fulfilled with netbeans, and a bit more hidden in emacs.
Even though limited, I like netbeans UML module (if there is one thing a mouse is good at, it is diagrams).
Wow, now that is some pretty cool stuff!
jess
www.anonymity.cz.tc
Have you tried the Anything package? Another compelling reason to use Emacs. I do not think any other editor has something like this:
http://www.emacswiki.org/cgi-bin/wiki/Anything
Thanks for the article, I really enjoyed it. I'm a former EMACS junkie and didn't switch until I found IntellJ IDEA (I work mostly in Java). Things I like are fast file switching (filename completion across the entire src tree). The remote editing thing isn't there, but many of the other features you listed are. The UI tries to be unobtrusive as possible, I rarely have to use the mouse, etc.
My main point is this: how many hours have you spent customizing/tweaking/learning EMACS? Many, I'd wager. I bet to a certain degree, EMACS has affected the way you work- sure you customized it, but the way it does things has hugely impacted the way you work.
Its highly unlikely that you'll just be able to waltz into any available editor and have it work just the way you want. I bet that any modern editor will have some capacity to do everything you want, but it will require tweaking, learning, adjusting. My advice is to look at a few, and dig in and learn the one you like the most, then check out another one, giving each the time to show you how awesome (or not) they are.
I am reading about the keystrokes that you use to open a file "bar-baz-boz-qux.c" in the same directory:
"control-x control-f b <tab> <enter>"
To do what you are describing, on a Mac, I press:
"Command-o b <enter>"
On windows, I think I would press:
"control-o b <enter>"
> Do I need to hit more buttons than that in your editor?
Yes, Emacs needs 5 vs. Mac and Windows only 3.
> Do I need to reach for the mouse?
No.
> Do I need to navigate the inefficient-even-from-the-keyboard GTK file dialog?
Maybe. Maybe the GTK file dialog sucks. I don't know. I do know that I like reading "One that uses modern UI conventions instead of arcana from the 70s so that my friends who are not emacs-heads can quickly wrap their heads around what's going on on my screen, and perhaps dare to touch my keyboard." because Emacs makes me go totally numb.
What am I missing here?
Well, VIM does all those things as well, and more of course.
@Mark Stock
With ido-mode (which is packaged --but not enabled by default -- with newer emacs) you don't even have to type the full name. It offers flexible completion (so pga.h will match "pg_aggregate.h") and instant auto-completion (with menus of choices) as well as buffer history searching (so you don't have to be adjacent to the file to open it).
Plus, how often do you open new buffers? Generally most emacs users simply never close them.
Have you ever looked at Epsilon from Luguru Software? www.lugaru.com
Mario - vim has a kill ring? That's news to me and I've been using it for 16 years. Anyway, vim certainly contains all the things glyph doesn't like about emacs as well. (I'm not sure whether it's worse or better; on the scale of "weird things your editor can confuse newbies with", modal vs. control commands nested two-deep is a coin toss for me.)
I feel like I should write the vim version of this, but I probably won't because I just don't think about my editor as much as glyph does. :-)
(Just found this implementation of a kill ring in vim: http://www.vim.org/scripts/script.php?script_id=1234. Gonna try that out - looks like it does the right things for a vim user.)
Great post!
I've been using emacs for a lot of years, and I still use it for most work. But for Java work I use Eclipse with its emacs key bindings. Eclipse provides almost everything I like about emacs, but with some additional great features like code completion, on-the-fly compilation, and ctrl-shift-F reformatting of an entire source file to conform to highly customizable formatting rules. Eclipse's Python and PHP modes seem good too (oddly, C/C++ modes not so much).
Great post! I remember some time ago I had like you the desire to switch to an editor/ide that feels more modern and that others can more easily wrap their heads around - but now have settled with accepting that I'll propably not leave emacs anytime soon. If ever. Discovering org-mode was the most notable influence, and propably the fact that I don't do any java development anymore where it certainly makes sense to use a better integrated IDE, but mostly web development with ruby plus a heterogenous bunch of all kinds of filetypes.
Thanks - your list of features improved my confidence in continuing to use emacs, even if that was not the intention ;). Allow me to share some tips below for the case you need to stick with emacs a bit longer, and some questions.
> Can you do what I mean when I press the "go" button?
Maybe offtopic because it doesn't fit to your workflow, but worth mentioning - the recompile function. I found it extremely useful when working on single tests, where I would need to go and edit several different implementation files (which in my case have no annotations that point to specific tests) to fix a particular issue. I added a little function save-and-recompile and bound it to C-x C-y - close enough to the standard save C-x C-s, but with an extra "run that last test again". A bit like autotest for ruby but with full control.
> Can I reach the thing I need to work on fast?
I'm used to most of the standard emacs keybindings but for things as fundamental as buffer / frame switching and killing, having to combine two keystrokes always annoyed me, I therefore highly recommend binding them to shorter ones as long as you stick with emacs. E.g. I have ido-switch-buffer bound to C-tab.
> Can I use it remotely over the internet? Collaboratively?
Would you elaborate a bit how you pair program over the internet? Do you simply have a console emacs open within a screen session, or something different? I'd love to be able to collaborate from within emacs running in X. make-frame-on-display is somehow nice but I never used it in practice.
> Can I tell what I'm working on?
Wow - thanks for reminding me of which-func-mode. This is just what I needed right now after getting lost in some larger ruby files with several classes defined.
I've tried Peppy [(ap)Proximated (x)Emacs Powered by Python] a few times, though not very recently. I think I'm in the same place -- I don't want to be all retro, but I want an editing environment that fits programmers, not something that started with the assumptions that everyone is a newbie (modern GUI conventions) and then added on from there. (vi and Emacs are really more alike than different in this regard)
Anyway, at least Peppy actually claims to be trying to be Emacs, which I appreciate.
Eclipse with PyDev.
You can even teach PyDev to use -*- testcase: ... -*- to run proper unit tests.
A few questions:
* When I hit C-x C-b I can't start typing to filter the list. Even if I switch to that buffer and start typing it doesn't do this. What am I missing?
* What are you using for the trailing whitespace stuff?
* Which vc mode are you using? Isn't hte standard vc-mode stuff terrible for things like Bazaar and Git?
* which-function-mode doesn't appear to do anything for me. I have it turned on but it doesn't show anything new in the status line. Any ideas?
@metajack regarding the filtering of file names - maybe ido-mode is not enabled? Try issuing a M-x ido-mode and then C-x C-b again.
"When I hit C-x C-b I can't start typing to filter the list. "
Try Anything. It does exactly that and much more:
http://www.emacswiki.org/cgi-bin/wiki/Anything
Is there a reason that associating modules with test modules is a feature of twisted-dev.el instead of trial?
Yes and Amen!
By the way, I think you meant "easy to be ambivalent", not "difficult to be ambivalent."
Well, VIM does have a kill ring of sorts. Instead of just yanking with yy you can do "xyy where x is any letter and yank to a register x. That way you get to keep up to 28 previous yanks if you care about them all.
Personally, if I think what I yanked will be needed later elsewhere as well I yank it to a register and keep it.
If what I yank is not needed except immediately to put it back once then I yank it to unnamed register.
Check this out: http://wiki.python.org/moin/PythonEditors
There are quite a few editors there. Just do a search for "great" and figure out which "great" suits you.
I'm pretty happy with TextMate.
Re the collaboration, have you heard about emacsclient? Type M-x server-start in your Emacs instance, then connect to it from another tty with emacsclient -tty, and it will connect to your emacs as another "instance".
It's like using Screen twice, except that with emacsclient it is a separate "instance" of each buffer, so that two people can type on the same buffer simultaneously at different cursor positions!
I've tried this with a friend, he connected over the internet with SSH, then typed emacsclient -tty, and we both edited the same buffer at the same time!
The issues are (1) it's not really meant for collaboration so it doesn't support things like (2) showing where the other user's cursor is and (3) what the other user has changed (like Gobby does), and (4) you can't type anything when another client is interacting with the minibuffer. But it's pretty neat and useful, and someone who is sufficiently skilled with Emacs might be able to add some of those Gobby-ish features to it.
Enjoy!
I have read through this post plus all the comments and Its clear that we have
different people of different interest and definately at differednt levels of
programmming. I use emacs alot, and more than any application in my system
though sometimes I have to juggle it with netbeans due to netbeans capability
to do on the fly syntax checking as well as autocompletion with suport for
javadoc for my java programs, and thats just about it, far as my need for
nebeans is concerned, the rest I can do with emacs only too well.
Well in my view, emacs is a programmers editor, not a normal users editor and
in most casees the people who will rub shoulders with emacs and 'wonder what
is happening to you screen' are diehard windows users who swear by the mouse,
menus and Open file dialogs box. To such users, the computer is completely
incomplete without menus, tool bars and the need to chase the mouse around like
a cat does. Key bindings are greatly emphasised in emacs and the need is to reduce
the time taken to 1) raise your head, 2) tell you brain you need the mouse
3) wait for you brain to send the appropriate interrupt to you hand 4) wait for your
hand to negotiate for the mouse ... and so on, and mind you this works over and over. Ofcourse you might argue that the time taken is insummountable but
consider doing thing over and over while editing a 300 lines file.
Emacs is not the best looking editor but its powerfull just like Linux has not
been the best looking OS until recently, but all along Linux has been powerfull
enought to run as servers in big companies like NASA and Google.Windows on the
other hand has been user friendly and more appealing to some eyes, but is that all
their is to an OS? Would you format you hard disk over and over after a virus
attack just so you can get back the "user friendly" Interface when someone else's
hard disk has stayed untouched since the first initial installation of a free OS?
Same applies to emacs, I dont want to Touch mouse> Click File Menu,>
No, its Edit Menu > Move to edit menu > Click the menu > Scroll down > select Preference > oh!I missed it, menu with drawn > restart the process . Haa,
I'd rather take a day learning, tweaking and hacking emacs then have an effective
editor for the entire year than spend an entire year going trough menus, tool
bars and dialogs. Thats. users can do too well, I am not just a user, am I?
So if anyone cant take the heat, get off the kitchen and join the million
other users being controlled by the computer, limited to what programmers
behind their programs implimented in the editors and play around with the mouse,
the menus plus even a [Next>>] [Next>>] dialog to open a file as short as main.c .
As for me, I'll go by emacs try vim if need be, after all its a programmers editor and thats what this is all about. Beside, its a lifestyle, my lifestyle. Happy Coding!
I have read through this post plus all the comments and Its clear that we have
different people of different interest and definately at differednt levels of
programmming. I use emacs alot, and more than any application in my system
though sometimes I have to juggle it with netbeans due to netbeans capability
to do on the fly syntax checking as well as autocompletion with suport for
javadoc for my java programs, and thats just about it, far as my need for
nebeans is concerned, the rest I can do with emacs only too well.
Well in my view, emacs is a programmers editor, not a normal users editor and
in most casees the people who will rub shoulders with emacs and 'wonder what
is happening to you screen' are diehard windows users who swear by the mouse,
menus and Open file dialogs box. To such users, the computer is completely
incomplete without menus, tool bars and the need to chase the mouse around like
a cat does. Key bindings are greatly emphasised in emacs and the need is to reduce
the time taken to 1) raise your head, 2) tell you brain you need the mouse
3) wait for you brain to send the appropriate interrupt to you hand 4) wait for your
hand to negotiate for the mouse ... and so on, and mind you this works over and over. Ofcourse you might argue that the time taken is insummountable but
consider doing thing over and over while editing a 300 lines file.
Emacs is not the best looking editor but its powerfull just like Linux has not
been the best looking OS until recently, but all along Linux has been powerfull
enought to run as servers in big companies like NASA and Google.Windows on the
other hand has been user friendly and more appealing to some eyes, but is that all
their is to an OS? Would you format you hard disk over and over after a virus
attack just so you can get back the "user friendly" Interface when someone else's
hard disk has stayed untouched since the first initial installation of a free OS?
Same applies to emacs, I dont want to Touch mouse> Click File Menu,>
No, its Edit Menu > Move to edit menu > Click the menu > Scroll down > select Preference > oh!I missed it, menu with drawn > restart the process . Haa,
I'd rather take a day learning, tweaking and hacking emacs then have an effective
editor for the entire year than spend an entire year going trough menus, tool
bars and dialogs. Thats. users can do too well, I am not just a user, am I?
So if anyone cant take the heat, get off the kitchen and join the million
other users being controlled by the computer, limited to what programmers
behind their programs implimented in the editors and play around with the mouse,
the menus plus even a [Next>>] [Next>>] dialog to open a file as short as main.c .
As for me, I'll go by emacs try vim if need be, after all its a programmers editor and thats what this is all about. Beside, its a lifestyle, my lifestyle. Happy Coding!
C-x Space and C-u Space don't do anything for me in emacs 23.1, but I've really wanted a generic go-back feature like you've described in your post. What are those keys bound to for you? Did you have to install a custom package?
Post a Comment