Monday, December 19, 2005

Emacs: The Straw that Broke the Camel's Back


I'm a Vim user, but I try to be pretty open minded. I've used Emacs extensively in the past, and in the interest of being flexible, I decided to revisit the Emacs tutorial. I memorized most of it. I originally switched away from Emacs when I was doing PHP programming, and Vim accomodated me better. Having approached Emacs with an open mind (I really would have liked to try it out for six months), these are the things that dissuaded me:

  • The syntax highlighting in Emacs cannot compare to that of Vim, especially in multi-mode files such as Cheetah. Here's a screenshot of Vim. Notice that it's able to handle Cheetah, Python, HTML, and JavaScript all in the same file.

  • I found myself with my pinky permanently glued to the control key when I was editing existing code. Does everyone else ignore the tutorial and use the arrow keys instead of C-[npfb]?

  • I'm stuck with FreeBSD 4.7 in a certain programming environment, and Emacs there didn't come with Python support at all! In contrast, with the exception of brand-new languages like Io, there's a mode in Vim already installed for almost every programming language I've ever used (e.g. Haskell, OCaml, etc.).

  • When committing a CVS file, it didn't make use of my CVS/Template, which is a must for my programming situation.

  • Being compulsive obsessive, it was a bit irritating having a buffer in my buffer list for everything. I far prefer just having a buffer shown for each file that I'm actually editing. I like to permanently close buffers, but this seems to be discouraged in Emacs. I'm sure this is just a matter of workflow, and it doesn't really matter. To be fair, I've customized Vim to show my open buffers along the top, like tabs.

  • The thing that broke the camel's back was when I noticed how nicely Vim syntax highlighted a diff I was reading. I then tried the same thing in Emacs, and it didn't syntax highlight at all. I'm sure it can do it, but it didn't by default.

As an aside, it's fair to say that neither Emacs nor Vim is especially user friendly. That's true. However, for me personally, since I edit text all day, everyday, I'll choose whatever is most powerful for the type of editing I do. Since I do this everyday, the initial learning curve is less important to me.

I'll keep my further comments to myself. To prevent a flamewar, please only respond if:

  • You know at least 20 hotkeys in each editor you're arguing about.

  • You approach the argument with an open mind.

  • You have coded for at least 2 months in each editor you're arguing about.

10 comments:

ChrisWoznitza said...
This comment has been removed by a blog administrator.
Anonymous said...

From: Jesse Montrose

On Tue, Dec 20, 2005 at 03:13:04PM +0000, JJinuxLand wrote:
> - The syntax highlighting in Emacs cannot compare to that of Vim,
> especially in multi-mode files such as Cheetah. Here's a screenshot
> of Vim (see below). Notice that it's able to handle Cheetah,
> Python, HTML, and JavaScript all in the same file.

That would kill it for me too. I just don't have to edit multimode
files.

> - I found myself with my pinky permanently glued to the control key
> when I was editing existing code. Does everyone else ignore the
> tutorial and use the arrow keys instead of C-[npfb]?

I use the arrows, but I also have caps-lock mapped to ctrl. Don't you?

> - I'm stuck with FreeBSD 4.7 in a certain programming environment,
> and Emacs there didn't come with Python support at all! In contrast,
> with the exception of brand-new languages like Io, there's a mode in
> Vim _already installed_ for almost every programming language I've
> ever used (e.g. Haskell, OCaml, etc.).

That's just an old version, it's there in emacs CVS (and at
python.org, I think). Installation is pretty easy, but you have to be
open to configuring, as there are a lot of these little things that
require tweaking to get the way you like them.

> - When committing a CVS file, it didn't make use of my CVS/Template,
> which is a must for my programming situation.

I've never understood that. I have it registered, so I get the
template with ^xgt, but I still don't know why the author didn't add
that.

> - Being compulsive obsessive, it was a bit irritating having a
> buffer in my buffer list for everything. I far prefer just having a
> buffer shown for each file that I'm actually editing. I like to
> permanently close buffers, but this seems to be discouraged in
> Emacs. I'm sure this is just a matter of workflow, and it doesn't
> really matter. To be fair, I've customized Vim to show my open
> buffers along the top, like tabs.

I suppose most emacs users keep lots of buffers open, but I don't see
anything in the design that discourages you from permanently closing
buffers.

> - The thing that broke the camel's back was when I noticed how
> nicely Vim syntax highlighted a diff I was reading. I then tried the
> same thing in Emacs, and it didn't syntax highlight at all. I'm sure
> it _can_ do it, but it didn't by default.

Yeah, mine does it. For what it's worth, emacs has a mode called
ediff that I believe to be the best diff in existence (I don't make
that claim about emacs in general). I'll give you a demo sometime.

> As an aside, it's fair to say that neither Emacs nor Vim is
> especially user friendly. That's true. However, _for me personally_,
> since I edit text all day, everyday, I'll choose whatever is _most
> powerful_ for the type of editing I do. Since I do this everyday,
> the initial learning curve is less important to me.

I'm strongly in that camp myself. I'd much rather spend time up front
learning a tool than spend a lifetime suffering for the sake of an
"easy to use" tool :)

> I'll keep my further comments to myself. To prevent a flamewar,
> please only respond if:
>
> - You know at least 20 hotkeys in each editor you're arguing about.
> - You approach the argument with an open mind.
> - You have coded for at least 2 months in each editor you're arguing about.

I think I still (barely) meet the requirements, although I'm not
arguing, I think you *should* use vi.

Anonymous said...

Ben Bangert said (roughly):

* You absolutely must swap Ctrl and Caps Lock.

* I do use c-[npbf].

* Use mmm-mode for multi-lingual syntax highlighting. I wrote the mode for Myghty.

Shannon -jj Behrens said...

It turns out my diff wasn't highlighted because I hadn't turned on syntax highlighting.

Anonymous said...

I am pretty experienced at both Emacs and Vim. I tend to prefer Emacs for development, and Vim for configuration files and system administration.

Emacs does have multi-mode support, but it's a pain to set up; vim clearly wins in that area. However, for me, multi-mode files are a code smell; if an HTML file has more than one expression worth of Python in it, or a Python file has more than one tag worth of HTML, I find that there is some kind of design mistake happening.

The real killer feature of Emacs that makes it the clear winner for development is the ability to asynchronously run processes and interact with buffers. Being able to jump between an active PDB session and the real editor for the source files involved is really helpful for visualization. Also, my unit tests take a looong time to run. I really like being able to whack the "unit test" key and keep coding.

In some absolute sense, Emacs is more powerful and Vim is faster. It depends on what you need - if your code involves editing groups of small files, in different languages, on different systems, then Vim is far better; working with Emacs in that environment leaves you spending most of your time waiting for the editor to start. In the opposite case, where you are working with large numbers of large files, in a big system, the implied workflow you noticed (wanting to keep lots of files open at once, wanting to keep the editor running) is a help rather than a hindrance.

Shannon -jj Behrens said...

> I am pretty experienced at both
> Emacs and Vim...

Quite helpful. Thanks!

Doug said...

All the stuff you mentioned I noticed JEdit already has. And JEdit is much easier to use since it has a GUI.
Just download some plugins like buffertabs, jython/jruby addins, console addin, jdiff, etc.

Shannon -jj Behrens said...

Yes, I've heard good thing about jEdit. It's open source, so that's good (actually, a requirement). It even has Haskell support ;) It doesn't have Cheetah support, but I could probably use the Velocity support as a guide to do it myself. It does have a plugin infrastructure. Perhaps the two things that are unfortunate are: 1) there's no console mode. I really like and use this feature in Vim. 2) It won't be fun trying to get this to run on my remote FreeBSD 4.7 system and use it over remote X. Of course, that situation is doable. I may give it a shot since I've heard good things about it. I have a suspicion it will require more actual (i.e. including shift, ctrl, etc.) keystrokes (count them!) than Vim to perform various tasks since it's modeless (consider silly tasks such as replacing 5 characters with a new word "5xi", deleting a blank line "dd", opening up a blank line "o", etc.), but I can almost guarantee it's easier to use (as I mentioned however, I'm *not* looking for an easy to use editor). I hope it doesn't force me to use the arrow keys ("hjkl" in Vi) or mouse (probably won't) since that involves moving my hand. By the way, I've come to the conclusion that it's a good idea to use an editor that makes sense for your programming language: Lisp->Emacs, Java->Eclipse, Visual Basic->Visual Studio, etc., but there's still room for weirdos like me who code in a ton of various languages for the simple joy of it. Gees, I guess I gotta go install Java now ;)

Matthias Benkard said...

I think I fulfill the requirements, so I'll throw in my € 0,02.

I actually love Emacs' keybindings. That's because I use a custom keyboard layout (kind of like Dvorak, but designed for the German language), which makes Vim's h/j/k/l navigation completely useless (it would be u/p/y/e on a QWERTY keyboard). They're also consistent, which makes them easy to remember: C-f = forward-char, M-f = forward-word and so on. Even if you don't know some particular keybinding, you can use M-x to run the command by name or use tab-completion to discover new features.

That said, Vim's syntax highlighting really is a whole lot better than Emacs'. But what really annoys me is Emacs' complete lack of proper text rendering. I mean, which century is this? Antialiased text is a must for my bad eyes, and Emacs doesn't provide it (except in Mac OS X, of course, but regarding font rendering that's in a whole different league altogether, anyway).

I find both editors' handling of multiple buffers horrible, by the way. I'd love to have a nice, graphical tab bar as well as a tree view of my project. I know of Speedbar and tabbar-mode for Emacs, but they're ugly and not really usable. Do you know of a good solution for Vim, by chance?

jEdit has got tabs and a graphical tree view, but its keybindings are terrible, there are no keybinding sets to choose from, and it consumes much more RAM than it should. Its syntax-highlighting support isn't as good as Vim's and Emacs', either. Not to mention the fact that its startup time is even worse than that of Emacs.

Oh well... maybe I should go back to using EDLIN.

Shannon -jj Behrens said...

Concerning tabs in Vim, I use the minibufexpl plugin. In my .vimrc, I have:

let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBuffs = 1
let g:miniBufExplModSelTarget = 1
map <C-PageUp> :bprev<CR>
map <C-PageDown> :bnext<CR>

It's not pretty, but it's very useful. I also recommend:

" Don't require that you save when switching to another buffer.
set hidden