Scrollbind
Fri, Apr 12, 2019Coding is writing. I spend hours a day writing in vim. My favorite keystrokes are second nature. Searching, replacing, moving the cursor around. It’s fast and efficient and easy on my hand, which typically starts to hurt after too much mousing, or worse, touchpadding.
And I spend hours a day working with git. Branching, diffing, committing, merging, pushing. It helps me understand exactly where my code is.
So when it’s time to write a translation, I’m loathe to give up on the tools I know so well and use so effectively. I translated A Well-Tempered Heart in vim. In the end I needed to deliver a Word document, and Markdown was not yet part of my world, so I marked it up as HTML and converted it. That was a little clunky, but the joy of using my preferred tools was worth it.
I’ve got a new project now, and I’m going to use vim again, but this time I’m
going to use Markdown alongside my favorite new trick: scrollbinding. With
scrollbind
I can have the original and my translation in two columns, side by
side, and linked so that they will scroll together. It’s hard to overstate how
helpful this is for translation.
So how am I doing it?
At the top of each file I have a modeline
, a line of instructions for vim
that will not show up in the output because it’s commented out. In the original
file it looks like this:
<!-- vim: set number scrollbind nospell tw=0 cursorbind : -->
This line tells vim to show line numbers (which helps me ensure that the two
texts are in sync), to scroll the texts together, to turn off the spelling, not
to use soft wrapping, and also to sync the cursor position between the two
texts. I don’t want to use these settings for other things I write, which is why
I’m adding them to a modeline rather than to my .vimrc
.
I have a similar modeline at the top of my translation file. The only difference is that I leave the spell-check on:
<!-- vim: set number scrollbind tw=0 cursorbind : -->
Then I open the documents with a command like this:
vim -O original.md translation.md
The -O
flag tells vim to open the documents side by side vertically. Once
they’re open I often find that I have to execute :syncbind
just once to get
them synced up. After that, it’s off to the races.