When it comes to text editing, it doesn’t get much better than
vim
—and by extension, MacVim. If this
is the first time you’ve heard of vim
, or the first time you’ve
seriously considered using it, please stop now and go read
Coming Home to Vim, by Steve Losh1. That
captures the Zen of Vim better than anything else I’ve read.
If you’re still around (or back), then congratulations: you have great
taste in editors. Now on to one of the most irritating things about
vim
: getting your vim
all tricked out with just the right set of
plugins, color schemes, and keybindings, then getting stuck on a remote
server somewhere with a vanilla version of vim
, or maybe even a
different vi
clone, like nvi
. Enter bcvi
.
bcvi
is a clever little tool that basically copies the file you want
to edit to your machine, invokes gvim
on it, then copies it back when
you are done. Presto: you get to edit in the comforts of your own,
highly optimized vim
environment.
All you need to do to get bcvi
is install it via CPAN;
it even comes with a couple of helper commands to give you handy shell
aliases, etc. But if you’re running OSX , oh-my-zsh
(if you’re not, go read Steve’s My Extravagant Zsh Prompt
for a good explanation of just how awesome it can be), and MacVim, then
there are a couple of things that you’ll probably want to do.
As an aside, you might want to update CPAN so it stops nagging you every
time you try to install something. The default perl
that ships with
OSX is under /usr/bin
, so upgrading CPAN is going to require sudo
.
It’s also rather old. If you’d rather, you can simply install a current
perl
via Homebrew. This will get you up-to-date and allow
you to upgrade CPAN without needing sudo. You could also look into
local::lib
, which I’ve used with success on servers.
The instructions I used (NOTE: some of these are probably unique to my
box, but I don’t have a spare handy to test) are:
1 2 3 |
|
With that out of the way, here’s how to get started with bcvi
on a Mac:
- Install
bcvi
. This is as simple asinstall App::BCVI
from the CPAN prompt. - To make
bcvi
use MacVim (or possibly even work, if you don’t have an X-based version ofvim
), you need to symlinkgvim
tomvim
. Since I have mymvim
situated in/usr/local/bin
, that’s where I put thegvim
symlink to it, as well. - Get those lovely aliases. Execute
bcvi --add-aliases
. NOTE: This only adds them to.bashrc
, so if you’re using ZSH, you need to copy and paste them to your.zshrc
. - Start the listener process. This is as simple as
bcvi --listener &
, but I would never remember to type this until the first time I tried to usebcvi
and it errored out. Instead, I use alaunchd
job. You can get it from this BitBucket repo. If you’ve never usedlaunchd
jobs before, instructions are included in the README. - Install
bcvi
on the remote servers where you’d like to use it usingbcvi --install hostname
. This will installbcvi
in$HOME/bin
, so permissions shouldn’t be a problem. - Finally, I like to add an alias so I don’t have to type
bcvi --wrap-ssh -- hostname
every time I connect to a server and want to have access tobcvi
. I added the following to my.zshrc
:
1
|
|
At this point, you should be able to ssh-bcvi
to your remote server,
find the file you need to edit, and vi filename
to edit it in the
comfort of your own vim
.
Back to flipping out…
-
As a matter of fact, just go read everything Steve writes. I steal ideas from him all the time.↩