Recent PhotosCalendarArchivesQuicksearch |
Thursday, November 1. 2007So long, Vim. I'm returning to Emacs
I'd been using Emacs for quite awhile, and about 8 months ago I decided I would try using Vim. I'd only used vi for system emergency work, but knew a number of people that swore by it for regular work. So I decided I would learn Vim and use it for my regular work. I figure that with things like this, I don't get a real feel for how well they work unless I use them for all my work. So I haven't really opened Emacs at all in the past 8 months.
Yesterday I finally decided that Vim was not living up to my expectations and I'm in the process of switching back to Emacs. I thought I ought to write down why I'm doing that, for my own future reference... and since nobody has ever written about Emacs vs. Vim, I might as well post it where everyone can see it. So here we are. Original Reasons for Using VimIt would lead to more comfortable typing. Lots of Vim users mention that you don't have to hold down keys while hitting other keys as much in Vim as in Emacs, and that the movement keys are all on the home row. That's true, but I didn't find it to be that big of an improvement, since Esc is a farther reach than anything in Emacs, and let me tell you, you're hitting Esc all the time in Vim. I found that removing the armrests from my chair made my hands happier than Vim ever did, and swapping Ctrl and CapsLock in Emacs will probably help there too. It starts faster. I'm not sure if that really was true even when I switched, but it certainly isn't true on any of my machines today. Both Vim and Emacs have had major version upgrades (v7 and v22, respectively) since I started using Vim. People seem to say that Emacs 22 feels faster, though I don't know if that's true. The startup times of the two, if they're different, are imperceptible. Vim would use less RAM. Frankly, these days, both Emacs and Vim are way down on the list of things that use up RAM. Heck, kmail has 141MB resident, and each of its two IMAP processes is using more than 30MB. Emacs in X right after start has 16MB resident, 10MB of which is shared, and 25MB VSS. gvim right after start has 8MB resident, 5MB of which is shared, and a 43MB VSS. Emacs tends to use fewer processes for things that vim. So they're not all that different, and Emacs could come out smaller in certain situations. But the difference is irrelevant on today's machines, and modern Gnome and KDE apps are many times larger than both of them. It will make me more comfortable in rescue environments where I have only traditional vi available. Actually, the vi on AIX is so different from modern Vim that this didn't really help. It would make me more productive. There are some editing commands that did, but as you'll see below, it was more than balanced out by other problems. Things I Liked about VimThe commands dt, dT, df, dF. Wonderful little things those. Emacs now has M-z (Zap), which is similar to df but can actually go to other lines (a nice addition). And there are easy ways to bind keys to the others as well, though that doesn't make it a pervasive convention like it is in Vim. Antialiased fonts. It's crazy that Emacs doesn't have this yet. But not a showstopper; I still like good ole 10x20 just fine. Regexp search-and-replace. Emacs actually has this now, and maybe it had it back then too. M-C-%. Apparently in Emacs22 the replacement expression can also have lisp code in it, which sounds really slick but I can't see myself using it regularly. Annoying Things in VimSyntax highlighting. The syntax highlighting for most languages in Vim felt like it was about as smart as it was in Emacs about 10 years ago. Strings like "Hello!\"" (in languages where \" inserts a literal ") often confused it. Sometimes quotes within comments confused it. Sometimes it would be confused permanently. Other times, just until I scrolled around in the file or reloaded it. Indentation. This is much more annoying than the syntax highlighting, really. In many languages -- and especially the two modes I've used most recently, XML and Haskell -- it really, really stinks. The indentation there isn't aware of syntax, or not very much. Sometimes it is smart enough to know that if an XML line starts with </ that it moves left and if it starts with an opening tag, that the next line moves right. But it's not smart enough to do this reliably. Not only that, but indentation is not handled with consistent configuration between languages. And even though Vim ships with a ton of language modes, the central docs only cover indentation for C. I've asked Vim experts about this, and have tried all sorts of various tweaks, have read through Vim indentation mode source files, etc. There is just no way to get it anywhere near the intelligence of Emacs for most languages, short of writing my own mode, it appears. This is even worse because when using the backspace key in insert mode, for awhile it deletes individual spaces, and then all of a sudden deletes a big chunk of whitespace back to the beginning of the line. (And no, the insertion of Tab characters is disabled.) Indentation is my #1 complaint about Vim, and something that shows no progress towards being fixed any time soon. And forget about anything like Emacs M-x reindent-region. This is a syntax-aware indenter. You can write out an entire source file with no indentation whatsoever, and it will indent the entire thing according to the indentation rules you've defined and the syntax of the language you're using. The best I've seen in Vim are commands that add or remove space at the beginning of every line in a region. In short, Emacs seems to "understand" the file format on a much deeper level than Vim, and can automate things to a much better extent because of it. Too many things disrupt the paste buffer. I can use Y or y to yank some text in Vim, and it's really, really easy to overwrite that buffer with other things. Yes, I know that I can yank it into a named buffer, but that's inconvenient and I don't usually know in advance that I'll have that need. In Emacs, only C-k and other "large area" commands disrupt it. Vim doesn't like you having lots of files open at once. It's surprisingly convoluted to do this. If you use the basic documented command to edit another file, :e, it closes the file you're working on. The normal way to open multiple files at once is to use split windows. Well, I don't like split windows all that well, and often just want to make a quick change in one file -- in full screen -- and then go back to another. Even though I use set hidden in my ~/.vimrc, it still is annoying and more convoluted than it should be. Vim can't create new top-level X windows. In Emacs, I can press C-x 5 2, and poof, I have a second Emacs window in X, and it's tied to the same editing session and Emacs process. Not a new process, with a different set of files, its own buffers, etc. The same process, same set of files. Just like a split window, but with a new top-level X window instead. gvim simply has no way to do that. This is also a large annoyance. gqap stinks. This has burned me more than once. I'll be editing an XML document, and insert some text in the middle of a paragraph. Now I have a really wide line. So I type gqap to reformat the paragraph. My cursor is near the bottom of the screen, so I don't really see much past the current line. I then save the document and exit. Later I discover that vim considered the entire rest of the document part of the single paragraph, and removed all the different indentation levels at </para> and the like, so it's completely messed up. Emacs is smart enough to know what is a paragraph in XML mode, and M-q does the right thing. Oh, and Emacs reindent-region can fix the Vim gqap-induced mess. Comments
Display comments as
(Linear | Threaded)
Vim can do dt across lines: use d/c<enter> to delete to the next character c. (And of course this can delete to an arbitrary pattern rather than just a single character like dt.)
I pretty much agree with the rest. Ben.
Right, the whole <do something> <through> <command that goes to new position> paradigm in Vim is really nice. I wish Emacs had that sort of idea pervasively as well.
I donno.
I tried print "Hello\"" in a python file... and that worked just great. It's 'always' worked as far as I know. Vim will do different sorts of syntax highlighting based on whqat type of file your dealing with. If I just open up a file with no extension or anything like that, just plain text, then syntax highlighting obviously doesn't work with the "hello\"" example. By default a lot of Vim's mode-detection stuff is disabled. Maybe that's the issue. Then with the autoindention stuff.. it's brilliant. Many many times I'd be editing a file or something like that and all of a sudden the 'auto indent' seemed to go all funky on my ass. It didn't work, it did stange things... Then I examined the source code and realised that I had missed a ) or a : or something important like that, and that the auto indent was the one acting correctly while I wasn't. I thought it was odd that you'd complain about this since both the highlighting and auto indent worked so well for me. Although this is all using python mode. I am more then willing to accept that there is large variations in quality between different language's syntax support.
What was your issue with using multiple buffers with "set hidden"? I don't know of any criticial distinction between using hidden mode (which should be the default IMO) in Vim and managing multiple buffers in Emacs -- to me they are functionally equivalent. Personally, I never use split windows. You may find one of these filesystem/buffer management plugins useful:
LustyExplorer -- http://www.vim.org/scripts/script.php?script_id=1890 fuzzyfinder -- http://www.vim.org/scripts/script.php?script_id=1984
I can't be certain, because I sorta gave up on it awhile back and just used multiple gvim instances, but I THINK these were the issues:
:n, to access the next file given on the command line, still wanted to close the current file. ISTR that :e didn't do the expected thing either, but I think there was some 4-character command that did what I wanted, but could never remember.
I don't think these commands behave this way, at least in my configuration -- however, I can certainly understand being frustrated with the awkward :e, :n, :prev, :b* interface.
If you feel like giving Vim another shot in the future, I do recommend one of the above plugins (or one of the many other similar plugins). They provide much more "emacsy" buffer management, very similar to find-file and iswitchb-mode. (Which are simply better than what Vim has to offer in a plain install.)
Hey - I understand your frustration with the buffer thing in vim. Long time back though I discovered the following mappings and stuck them in my .vimrc:
nnoremap <C-Tab> :bnext<CR> nnoremap <S-C-Tab> :bprevious<CR> Then you can essentially hit "Ctrl-Tab" and "Ctrl-Shift-Tab" to switch between buffers. So if you're editing one and need to do something quick in the other just ":e other_file.txt" as suggested, edit it and then hit "Ctrl-Tab" to go back (or better yet, if you're really done with it hit ":bd" to delete the buffer you just opened since you're now done with it). Also, in Vim 7+ try ":tabe" which opens up a file in a new tab. Then "gt" or "gT" switches forward and back (respectively) between tabs.
I stand corrected. I have checked, and :e behaves as you stated under set hidden.
It may be that Vim's Python mode is as good as the Python mode in Emacs, but I just didn't do much Python work during the time I used Vim. The modes I did use regularly were certainly not as good as the ones in Emacs. What you describe for Vim's Python mode sounds like what I expect out of every language in Emacs, including markup languages and other more obscure ones. Quite frankly, I expected it out of Vim going into the project too, and was disappointed to discover that the Vim modes were not consistently high-quality.
With autoindent on, =[range] will reindent based on the language. I often wind up using =% to reindent a function after I've refactored it.
On hitting Esc -- have you tried Ctrl-[? This can be really quite convenient if you remap CapsLock to Ctrl, as your hand doesn't even need to leave the home row.
On opening many files -- have you tried :tabnew or :tabedit? On formatting with gq -- paragraphs are defined in a strange way in Vim; all consecutive non-blank lines are in a paragraph. If you just want to reformat the line, you could use gqq instead. Lots of love, and have fun back in emacs, ~d
Perhaps I'm just not understanding what you want to do, but :e in vim will just open a new buffer with the new file in it. The old buffer is still there (:buffers to display all buffers). You can switch buffers at any time, no split required. In vim splits and buffers are orthogonal. You can have multiple split panes open on a single buffer, or have each pane be a view on a separate buffer.
Check the vim manual.. :e really closes the current buffer. It may remember where you were, but it wants you to save before switching. I want to have multiple ones open at the same time.
Hi John, that is only the case if you are not using "set hidden". For anyone using Vim as a development environment, this is pretty much a mandatory option.
You bailed on vim too early. Vim is kind of like Spider-man. Only with Spider-man the qualifier is responsibility, with vim it's a steep learning curve.
Your complaints seem to be that vim doesn't work for you out of the box. That's not a reason to dump it. Vim is infinitely customizable, but it just takes time to figure out how. For example, the Minibufexplorer plugin solves two of your problems.
The *biggest* problem is the indentation in Haskell and XML. I have searched extensively for solutions to that. Yes, I *could* write my own, but learning how to do that -- and getting it done right -- would wipe out any productivity gains I'd get from using vim for maybe the next couple of years or more. Not worth it to me, when Emacs has working indent modes for every language I try.
I have tried to avoid using too many nonstandard plugins, both in vim and emacs. Hard to maintain when you work on lots of machines, may not be updated when vim is, etc. I did use the nonstandard Haskell mode in vim, which helped, but I believe I limited myself to that. I use the Debian haskell-mode package in Emacs. (I don't mind them if they're in Debian packages, because then they can be kept up-to-date automatically) So yes, I accept that plugins could help some of this. But not the biggest pain.
There are various scripts to keep your VIM runtime up to date. Also, using the VCS of your choice to keep your RC files in one handy bundle should be pretty much standard, these days :)
Emacs 23 will have antialised fonts.
Ubuntu packages for CVS version available here: http://peadrop.com/blog/2007/09/17/pretty-emacs-reloaded/
What is Skynet? Google turned up a bunch of hits, but none seemed relevant.
Defense network computers. New... powerful... hooked into everything, trusted to run it all. They say it got smart, a new order of intelligence. Then it saw all people as a threat, not just the ones on the other side. Decided our fate in a microsecond: extermination.
I agree with all of the problems listed with vim. As has already been said, the flexibility is there to fix some things quickly. Unfortunately at the point when it comes to the scripts which control syntax and indentation the learning curve is undefined.
I am currently working mostly in Java, XML and PHP. Though I have hacked a solution together to syntax-highlight PHP and XML in the same document and find the indentation sufficient for my purposes, I frequently find myself working around the automatic indentation. Though I must admit the temptation to "give up" is real, the religious fervour in me assures me that a few more lines in ~/.vimrc will solve all my problems, if only I could find the right tip. Perhaps someone needs to contact the xml.vim maintainers and get it fixed once and for all! When I worked in Haskell last year, I do not remember having smart indentation on at the time, and I was only writing small programs, so I was quite comfortable. However, the popularity of the language is such that I concede that it may be a long time before an intelligent indentation script is written, unless a friendly emacs convert comes and helps out. :)
Yeow, Zing! ;-)
Actually, Python borrows heavily from Haskell syntax in a lot of ways. I wonder if someone hacked up the Python mode a bit...
When you open a file with :e it doesn't close the file you're working on. It keeps it in a buffer. You can switch back and forth between full screen opened files with :bn, :bp, :b <number> or :b <filename>
I'm a hardcore Vim user, and it's true, Vim doesn't understand the syntax of most languages at a deep level. I think that's because the vim script/configuration language isn't really all that powerful, and its easier to parse in elisp. Lisp in general is pretty good at that stuff. As a consequence, syntax highlighting is alright, basically just all the keywords and not much more. Indentation also sucks for languages like Haskell with subtle indentation patterns. Python is simple, do a new indent on lines after a line ending in :. Vim also has good indentation for Scheme/Lisp, which are also pretty easy to parse.
I think your other complaints are fixable, but I agree that the above is a real fault in Vim.
I know that vim should probably take things into account, but if the language has a difficult syntax to highlight, then that language has a problem. Vim should do it yes, fine. I found that finding which option to change to simply activate fontlock, (which apparently means syntax highlighting) for emacs far to annoying. To me, vim has a short learning curve. With emacs, there's so much crap, it's hard to tell what it is you want to know.
Re: autoindent, I'm a long time Emacs user but I really miss vi-style dumb, non-syntax aware autoindent every time I end up using a less than polished language mode. I have my own set of functions to do sorta kinda the same thing, but they aren't really good enough, at least yet, to publish.
NEVER USE ESC !
Use the ctrl+c instead !
Or use Control-[ instead if you really need to press escape.
there are slight differences between Control-C and Control-[
What the hell are you guys talking about? Is it really that bad? Can't programmers google anymore? Swap Caps and Escape insensitive clods. Here's the xmodmap to do that:
! swap caps and escape remove Lock = Caps_Lock keysym Escape = Caps_Lock keysym Caps_Lock = Escape add Lock = Caps_Lock You can do the same thing for the linux console with this: keycode 1 = Caps_Lock keycode 58 = Escape Indentation works in vim for everything but Haskell. Have you tried :filetype indent on yet? I've been a former Emacs user myself, changed to vim a year ago after my RSI... it *helped*! But, to be serious, both suck. Vim's major flaws are: it's folding is just plain broken. It just doesn't work reliably. And using this half-hearted vimscript thing as a backend was a wrong decision. Having a complete language to back your editor configs up (like emacs) would be waaaay better. One *very* nice thing about vim is the eclim-plugin - vim-integration to eclipse! Yay!
One thing, which really set me off, using vim is, that I'm using a non-US keyboard. For regular characters, things are the same, but specialchars are placed at different locations, some require pressing Alt Gr. This means that a lot of the standard commands (For example, pressing Ctrl+[ is rather awkward) aren't as "home-row" as they are sold as.
Oh, and as mentioned, Emacs 23 has smooth fonts. Highly recommended.
M-x viper. I can't imagine (well, I can but I won't) using emacs without it. I switched from gvim because the installation I had to use at that time crashed once too often, and I gave emacs a chance. But not without the vi emulation.
Since vim 7, you can use :tabnew (and other assorted commands) to open up new tabs, each of which can have multiple windows. Map this to keys, and you have a much better way of working with multiple files at once.
And :e does *not* close the previous file. That file is still in a buffer, and you can switch between buffers using :b# Cheers.
I think you need to spend a little more time with the vim tutorial - as the previous commenter mentioned - :e doesn't close the previous file.
The messing with the paste buffer thing is totally true though. Personally I think it really depends on what you're looking to do and how familiar you are with Unix systems. I think this site breaks it down nicely: http://comparati.com/1084-vi-vs-Emacs Basically - have some time to spare, and know Unix well? Use Vim. Else - Emacs.
Did you get to try M-x viper-mode ? Best of both worlds IMHO
Swapping escape with CapsLock is a must for vim. Try it, you'll never go back.
Hello. Though I haven't read all of what you wrote yet, I'd just like to say that Control-[ has the same function as Esc in gVim.
Automatic indentation of blocks can be done with the visual marking and the == command.
I have this line in my .vimrc because I tend to use it quite much: map <Tab> == I do agree with the paste buffer thingy though. Although I've gotten quite used to it after a couple of years of Vim abu... use. :) |
The ChangelogMost Popular TagsSyndicate This BlogCommentsTshepang about Imagine 1 Fri, 16.05.2008 15:19 Quite a painful story you tell , making me feel so god damn l ucky. Interestingly, here in S outh Africa, there's bee [...] Jon about Thoughtfulness on the OpenSSL bug Thu, 15.05.2008 05:01 In general, it is impossible t o prove that something is rand om, and difficult to ascertain that something is suffi [...] crf about Thoughtfulness on the OpenSSL bug Thu, 15.05.2008 00:24 There should be testing of pat ched programs before they are released, when feasible. This bug could have been caug [...] John Goerzen about Thoughtfulness on the OpenSSL bug Wed, 14.05.2008 16:58 Sure, it's only modifiable if it's a pointer... but pointers are the only practical way to pass many things: strin [...] jldugger about Thoughtfulness on the OpenSSL bug Wed, 14.05.2008 16:47 "Especially since you may be d ealing with functions that cal l other functions 5 deep, and one of those functions m [...] Russ about Imagine 1 Wed, 14.05.2008 16:22 Imagine that you are knowingly breaking the law by not apply ing for the appropriate visas. Not only that, but you [...] John Goerzen about Imagine 1 Tue, 13.05.2008 18:59 I have heard that argument bef ore, and frankly, I'm unconvin ced. I am not aware of any Am erican jurisdiction wher [...] John Goerzen about Imagine 1 Tue, 13.05.2008 18:55 What a wonderful point and pos t. You're quite right, and it 's high time we all revisit th e notion that legality d [...] Blog Administration |

Yesterday's post about switching back to Emacs saw quite a few comments from people (most of them useful, even). I learned a few things. My biggest gripe about Vim was that for the file types I worked with most, its indentation and syntax highlighting
Tracked: Nov 02, 04:39