Somewhere Between Vim and Emacs There is a Great Text Editor

Posted on April 13, 2008
Filed Under Computer Science |

Or: Yes, I’m The 300th Person To Write This Blog Post.

A year and a half ago, I abandoned Visual Studio to try to use the two most popular code editors: Vim and Emacs. Both of them have their advantages, but fall short of being the perfect editor.

Vim

The first coder’s text editor I used was Vim. It took quite a while to get past its infamous learning curve, but once I did, it was wonderful.

Advantages

Disadvantages

Emacs

Disclaimer: So that I don’t summon RMS from the depths of the Marianas Trench, mentally replace all instances of “Emacs” with “GNU Emacs”. It’s easier to type, and everyone knows what I meant, dammit.

Note: In key sequences, “C” means <Ctrl> and “M” means <Alt>. So C-M-Del means “<Ctrl><Alt><Del>”

Advantages

Disadvantages

Somewhere There Is a Great Text Editor

Both of the text editors mentioned here have a lot of great features, but they also have a lot of drawbacks that are not mentioned here. Some certain commands have a lot more overhead then they should. Granted, you can just rebind keys to the command you want. However, this doesn’t always work when you are bouncing back-and-forth between a lot of different computers.

It would be great if Vim had the “kitchen sink” philosophy of Emacs built in, because then I’d never have to leave Vim and could forever revel in its modal glory. A lot of the buffer/window/tab commands in Vim feel like they have too much typing overhead. For example, typing “:tabn” over and over again to switch tabs gets old.

In turn, it would be great if Emacs had a lot less typing overhead for some of its commands. Viper (using VI bindings in Emacs) is a fair compromise, but it somehow feels cheap, and doesn’t really get away from the Ragtime Typing problem for anything but the most common movements.

In general, I’ve found that Emacs is a better writer than Vim, as it understands the structure of the document much better. However, I’ve found that Vim is a much better editor: I can perform a lot of the common editing commands a lot faster in Vim than in Emacs. It’s missing a few, like word dragging, but that is easily replaced by deleting the word and retyping it in the necessary location.

I think that a great text editor would have the following criteria:

Anything else?

Popularity: 60% [?]

Comments

21 Responses to “Somewhere Between Vim and Emacs There is a Great Text Editor”

  1. Zubin on April 14th, 2008 2:38 am

    “I can perform a lot of the common editing commands a lot faster in Vim than in Emacs. It’s missing a few, like word dragging, but that is easily replaced by deleting the word and retyping it in the necessary location.”

    You can actually just ‘d’elete and ‘p’aste it where you want it, a raw delete in vim always cuts to the main register. You can also use a different register with “r (where r is the register, not a command).

    Overall I agree with you to a degree, vim is optimized for opening and closing instances quickly, instead of having lots of tabs and windows (many panes in a single tab/instance). The repeated opening and closing paradigm is usually abandoned in a large scale project.

  2. Mikael Jansson on April 14th, 2008 2:41 am

    Regarding the long lines, I found this simple mapping helped tremendously in dealing with them (goes into your .vimrc):

    noremap j gj
    noremap k gk

    This allows you to navigate /within/ long lines, just as if they were multiple lines, without breaking them up!

  3. pavan on April 14th, 2008 3:29 am

    good observations.
    I tried switching to emacs from vim and it wasn’t a good experience for me.

    Vim was sufficient but the goodies/plugins that emacs offers seems to be irrestible.

  4. kana on April 14th, 2008 3:50 am

    >A lot of the buffer/window/tab commands in Vim feel like they have too much typing overhead.
    Why don’t you customize key mappings to execute that commands?

  5. Mathias on April 14th, 2008 7:05 am

    I see you tried out Viper. I don’t use it myself since I don’t know vi(m) very well. If there are any special drawbacks to it I am sure the Emacs (yes, it is OK to not write GNU Emacs, I have never seen RMS wanting that) developers might accept feature requests. I like the Vim philosophy but to me it seems it would be awkward when both modifying and entering text. Doesn’t that require you to do a lot of switching between command and editing mode?

    I use Emacs not only as a editor but as a application development platform. When you know elisp it is very convenient to hack together small utilities and tools. I use it for playing music, I do IRC, I chat with a powerful Jabber client, I watch movies, I download radio shows, I upload and manage Flickr images, etc…

    Good luck in the search of The editor! :)

  6. Fabio Cevasco on April 14th, 2008 7:10 am

    I more or less agree with all the “criteria” you mentioned for the perfect editor. I normally use VIM, although I’m far from being an expert because the learning curve is quite steep.

    I don’t agree too much with the “Kitchen Sink” philosophy: I’d like something fast to launch, which behaves like an editor and feels like an editor. Just that!

    Basically I’d like a VIM with a friendlier commands, built-in chord modifiers (although remapping keys does the trick, most of the times), and easily scriptable *natively*.

  7. Mathias on April 14th, 2008 7:19 am

    Fabio, have you tried emacs -Q? It’s quite fast on modern systems. Granted, not as fast as Vim. Also, Emacs users seldom close Emacs. We keep it running all day/week/month/year on and use emacsclient to make it open a new file (when you are in a shell, for example, from inside Emacs you use C-x C-f (or whatever easier binding you might have added) as usual, of course).

  8. Richard Howard on April 14th, 2008 10:47 am

    :tabn[ext]? Bleh! Use gt.

    also, gT = :tabp

  9. John Reese on April 14th, 2008 11:01 am

    Regarding Vim’s understanding of tabbing for source code, enabling the FileType plugin is a godsend. It actually detects the type of the file being edited (either by file extension or #!/… header, etc), and it then performs smart indenting while editing based on language syntaxes (ie, auto-indenting after { } characters, or …: in Python, etc).

  10. Sam on April 14th, 2008 3:40 pm

    On most default installations of vim you should be able to use ctrl+pgdown/pgup to move back and forth between tabs. And if there’s really a tricky command you use very often you should probably try to look into remapping it to an easier keycombo.

    And if I understood your “word dragging” correctly you should be able to perform the same by using dw to delete word and then just w to move forward one word and then P to paste in front of that word.

  11. s on April 14th, 2008 4:35 pm

    I wonder if Emacs with a footpedal for CTRL would be any good.

    Or, VIM where you used a foot pedal to either toggle modes (normal/insert), or where it stays in insert but the pedal engages normal mode while pressed.

    (I think this would be better as it would reduce ‘emacs-pinky’ syndrome and ‘running out of convenient, comfortable, memorable shortcuts’)

    “”"Why don’t you customize key mappings to execute that commands?”"”

    How can you know that you aren’t overriding some existing shortcuts? Which shortcuts are not used in any modes under any circumstances I might be in?

  12. shannos on April 14th, 2008 4:42 pm

    I use “gt” to get next tab.

  13. jeo on April 14th, 2008 7:29 pm

    Hmm, there’s an emacs mode that extends viper, supposedly to almost full vim emulation, I forget what it’s called…

  14. Tom Ritchford on April 15th, 2008 1:18 pm

    “Modal” (by which you mean “alphabetic keys are sometimes commands”)!? Why would you want that?

    Sure, I’m biased after over two decades of emacs, but look at the most popular development systems, Eclipse, VB/C++ system - NONE of them are modal - the c key is just a c key.

    My email client is not modal; my browser is not modal; Google docs/MS word aren’t modal.

    I type a lot, I’m used to just sitting down and typing. The fact that I can cause huge damage to my file this way in vi doing something that works on EVERY other editor I have in my life.

  15. Mark Wilden on April 15th, 2008 3:04 pm

    @s: I’ve long thought that your feet could be put to good use while typing.

    Why not have a foot mouse? With a pedal instead of a button? Then you could use the pedal for a Control key, as you describe.

    It would be called a rat.

    ///ark

  16. Jake on April 15th, 2008 3:51 pm

    @Tom:

    I agree that most ordinary applications should not be modal.

    However, I use my text editor to code for 5 or 6 hours a day, so taking the time to learn a new methodology for editing makes sense if it is more efficient. Vim is an expert system, not a beginner’s text editor, so modality helps tremendously when you take the time to learn how it works in all modes.

    Emacs, for example, uses C-v as a navigation, and C-y to paste from the clipboard. On a Windows machine, this goes against the grain of being able to do the same thing in every application, but it still helps make editing more efficient. This is perfectly fine, because Emacs is specialized for coding. This is a situation where YMMV. Taking the extra time to learn the different modes is, indeed, extra time. However, I’ve found that over the long haul, it works best for me.

  17. Ycros on April 16th, 2008 8:15 am

    I totally agree with this post, I recently (about 3-4 months ago) switched to using Emacs after being a Vim user for years. I love the Vim keybindings and editing, but Emacs is so much better as a whole IDE.

  18. Naan Yaar on May 17th, 2008 12:46 am

    Hi,

    I have been using Viper in XEmacs with the “expert” level set to 5. It has worked wonderfully, allowing me to use the best of both editors. I completely agree regarding the need to have “kitchen sink” capability and modal editing.

    In Viper, I tend to use XEmacs keystrokes when I am in insert mode and use vi keystrokes for mostly everything else. The save and undo key combinations in XEmacs come in handy and I tend to use them a lot. Also, dabbrev-complete is unbelievably useful for any editing; I cannot live without this.

    Why do you believe Viper is not the way to go?

  19. Jake on May 17th, 2008 11:23 am

    @Naan:

    A Vim user who is looking to customize their environment would do well to consider Viper in X/Emacs and take advantage of the macros/modes that Emacs has to offer, but an Emacs user doesn’t necessarily pick up any big win by using Viper in Emacs. This comes down to something I said in the post: Vim is a better editor, but Emacs is a better writer.

    With Emacs, all of the editing power is available as you are writing code for the first time (the time when you make the most mistakes). Emacs has a lower barrier to edit what you just wrote.

    It does make sense for an Emacs user to turn on Viper mode after they have written something and have started maintaining it, as editing in Vim is certainly quicker than in Emacs (in my own experience with both editors). However, I suspect that many people either won’t make that distinction, or don’t want to learn two whole editing paradigms for one task.

    If you have good results with Viper, then by all means, you should keep using Viper. Text editing is unique to everybody, so keep doing what works for you.

  20. webr on July 13th, 2008 7:21 pm

    joe: vimpulse

  21. Moxley Stratton on July 13th, 2008 11:14 pm

    I too have given VIM and Emacs some rigorous workouts. Two times as an experiment, I have switched from one editor to the other, mid-project.

    They both have their strengths and weaknesses. I like Emacs better overall. I think it has better buffer management, better search, and better replace. It integrates with the shell, and it has a nice API.

    My favorite feature of Emacs is this: Emacs keeps a stack memory of where you jump around your buffer. You can always get back to where you where by hitting C-u C-SPACE a few times (it’s easier than it looks). This is an extremely useful feature that no other editor has, as far as I know.

    Both editors suck at keeping compatible with the key bindings of modern, windowed applications. Except, to a small extent OS X, which provides Emacs’ core key bindings for all its editing fields, and this extends to third-party applications as well.

Leave a Reply