Two Things I Learned About Vim from an Emacs User
Yesterday I was working on a problem with an Emacs wizard, and I saw him do a couple things in Emacs that made me squirm. You see, I badger and belittle him at every opportunity for not embracing The One True Editor, but I saw him perform two actions in Emacs that I didn’t know how to do in Vim. And no way was I going to admit that, at least not to him.
Here are the two items:
When he ran a command from a shell with a lot of output, he piped the output directly to Emacs like this:
$ some_command | ecbuffer
I’m on a Mac, so I typically do this:
$ some_command | pbcopy
And then I open a new MacVim window and hit Shift+P to paste (I use the system clipboard in Vim). Inelegant in comparison. So, while his back was turned, I googled and discovered that passing - to vim causes vim to read from stdin, so I can just do this:
$ some_command | mvim -
Works great! I breathed one sigh of relief, but still had a second item to tackle: we were trying to solve a build issue in which a required jar file was not being included in the 1.2GB deployment file (that’s not a typo — we really roll that large). I noticed that when he opened a zip file in Emacs, it churned for awhile (hey — 1.2GB is a lot of data!), and then showed the zip file’s table of contents. Cool! My best thought for how to do that in Vim, using what I’d just discovered, was this:
$ jar tf foo.zip | mvim -
Not bad, but not as cool as what my coworker was doing in Emacs. So, before getting too worked up, I tried opening the zip file in Vim to see what would happen. Immediately, the table of contents for the zip file appeared in Vim. No churning. No wait. And then I could press Enter on one of the file names to view the file contents.
So, my Emacs-loving coworker made me learn two cool things about Vim. I need to work with him more often!