Friday, September 25, 2009

Do text editors *have* to suck?

Something I was thinking about this past week - the tools we use as programmers. Specifically, I was thinking about the all-important text editor.

When I started out programming, I would just use whatever was around. In DOS, it was EDIT.EXE. In Windows, I began with Notepad then proceeded to try a million different other things until settling on Notepad++ most of the time. I've used Eclipse quite a bit, but that's so much more than an editor, and while I liked it I found it far too heavy for my usual day-to-day work.

In parallel with my progression in M$-land I've led a second life extensively using Linux and Solaris (and other *nix-en). When I started in 1996 or so I think my primary text editor was pico... which I found after being baffled by vi, finding ed useless, and completely unable to figure out emacs. I eventually found joe and was happy for a year or two, until college.

In college we received cheat-sheets for vim and emacs, and both were still quite intimidating to me, so I continued to use joe, even compiling it in my home directory on systems where it was unavailable. However at this time I found myself beginning to hit joe's limitations and realized I had to bite the bullet.

I was still afraid of emacs, so I've been a vim user ever since.

So, here I am, ten years later, still using vim, and here's the part I hate: I've never mastered it.

I have memory-mapped all the common keystrokes for moving around a file, searching, replacing, mark, cut, paste, etc... but for anything else I need to consult a cheat sheet. This feels like a a failure on my part...

There are features I see emacs users have that I want *desperately* yet they feel out of reach in vim. Sure, vim can do some of them, split-pane editing, multiple files open at once, cutting and pasting between them, macros, shells, compiler/interpreter/debugger integration but all of this seems to never work the way I want it to.

I've ignored the elephant (gnu?) in the room for all this time: emacs. So, in the last year I made up my mind that I *must* learn to use emacs, at least as well as I do vim, and this week I did all my non-work hacking in emacs.

You know what I'm beginning to believe?


Yes, emacs is ultimately customizable. In fact, I've spent more time this week writing elisp than I have Perl, and yet, I'm still dissatisfied. Countless searches on Google have showed me that most people eventually give up fighting its quirks and just settle.

I have to admit, I'm beginning to get comfortable with all the keystroke-combinations, and the macros and slowly figuring out how to customize various things to my liking...

And of course, there's one more big problem: vim (or at least vi) is installed *everywhere* and I spend most of my time working on remote servers. Sure, I have root on most of them, but that's no reason to start installing things just because I feel like it.

Also, emacs seems to be quite a different beast running in an xterm over ssh, whereas vim remains the same.

I'm torn and frustrated. I need the best of both worlds and I need to figure out how to get them before I begin an epic yak shaving expedition that will ultimately suck my life away.

Maybe I'm just writing this to vent. Yes, that's probably it. Maybe in another few weeks I'll be singing the praises of emacs. Maybe I'll return to the relative comfort of vim.

If anybody reading this has tips for a reasonably-intelligent Perl hacker who just wants to get more out of his editor without moving heaven and earth and re-mapping every key-stroke to custom macros, please, please help!!!


  1. I now use TextMate a lot. Yes, you have to pay for it but it's really neat, and it's not entirely language centric, it's just for all needs. It's not a huge bloated IDE, it has some mild Perl support and in general it's all I need and make me productive and fast.

  2. I can relate. I used to do what you are doing a lot, but I'm at the point now where I've learned a *lot* of what vim has to offer and I'm pretty much settled on it. A lot of the cool things you mention can be faked with screen (split) and vim + a regular terminal. It's not great, but it always works. Also the vim ML and irc channel can be a great help to get things to work. One thing I like to do is peruse the help doc for something I want to do (admittedly sometimes a huge hassle) and then make a sticky note of the key combo on my monitor. I try as much as possible to memorize all of them. Anyway, Good luck!

  3. If you're doing remote emacs work and you're not using TRAMP mode, you're basically doing it wrong. You don't need to have emacs installed remotely because your local install will let you transparently edit remote files using this mode. I can't recommend it enough.

  4. Have you tried perl-support module for vim? Works great and it's not very difficult to customize.

  5. I used to be just like that with vim. Then one day I sat over the shoulder of a guy who was an absolute vim wizard.

    I would search the help file for a feature I saw him use, and then try it out myself. If I couldn't find the feature (due to me not knowing what the name was) I'd just start from the beginning. And I'd find little hints and tips I'd slowly start picking up.

    I also used to peruse the tips section of the website for fun and profit. Every time I read about something neat, I'd immediately try to make use of it a few times. And then tried to use it the next day.

    Some things stuck, others did not. I just slowly started accumulating tips and tricks, and before I knew it I probably appear as wizardly as the guy over whose shoulder I originally surfed and awed over his vim wizardry.

  6. I totally agree with David Nusinow. Emacs and tramp is the way to go. Don't ssh in and run Emacs; have Emacs ssh in for you. Tramp is included in recent versions of Emacs.

    The same goes for Vim. With netrw, you can open remote files almost as easily as local ones. Netrw is included in recent versions of Vim.

  7. Have you had a look at Padre yet?

    Remote editing isn't supported yet, but it's coming.

  8. Wow, I need to configure blogger to email me when people comment. Thanks for all the advice!

    I'll definitely try out TRAMP for emacs and netrw for vim. If I can get either one to make multiple ssh hops I'll be in heaven.

    I really like the emacs model of buffers-windows-frames from one process. I greatly prefer multiple windows over split-windows and I frequently cut-and paste between terminals running vim and I have to use the mouse which can be a PITA. One thing I've grown to love with emacs is being able to simply kill the text in one frame, alt-tab to another, then yank, all sans mouse.

    Of course, I already have a well-tuned .vimrc with everything set just the way I like it for coding... and fighting with CPerl is annoying.

    Currently, I just let CPerl do whatever it wants to my code then I call an emacs macro I wrote that runs perltidy over the sub/selection/buffer to put it into my preferred style. (still needs some manual tweaking, but, meh...)

    About Padre: I *like* padre, but it doesn't fit my needs for the work I do the most right now. However, I may find it useful in the near future for a refactoring project where I think I will want decent code-browsing among other things.

  9. Text Editors do suck. I am doing coding on windows and I can't even find a text editor with basic project capability that has color themes!! COLOR THEMES! Sorry, but it's ridiculous to code on a white background IMO, all I want is a dark theme without having to edit 50 different syntax highlight colors like Ultra Edit.

    Take BBEDIT for the Mac. Very good. Go through there tards.