I like vim, and I like getting things done from the command line. Google Docs is also good at what it does — sharing, comments, revision history all come for free.
Google Docs now supports Markdown import and export natively, which makes connecting the two a natural thing to do: the document stays in Docs, the editing happens in vim. So I wrote a small tool for it, gdoc-vim.
Installing
pipx install gdoc-vim
Usage
To edit an existing document, paste the URL straight from your browser’s address bar:
gdoc-vim https://docs.google.com/document/d/FILE_ID/edit
It exports the document as Markdown and opens it in vim (or whatever $EDITOR points at). When you :wq, the content is converted back and written to the same document — same link, same sharing settings, revision history intact.
You can also start a new document and go straight to writing:
gdoc-vim -n "Meeting notes"
Using a different editor
The name says vim, but any editor works — it honors $EDITOR:
export EDITOR=emacs
For GUI editors, add whatever flag makes them block, e.g. export EDITOR="code --wait". Otherwise the command returns immediately and the tool sees an unchanged file.
Google authorization
The first run needs Google authorization set up: you create your own OAuth client in the Google Cloud Console. It takes about three minutes, once. The tool prints step-by-step instructions in the terminal the first time you run it.
One thing worth knowing: a new OAuth client starts in “Testing” status, and in that state the tokens Google issues expire after 7 days, so you’d have to re-authorize every week. Setting the publishing status to “In production” in the Console fixes it, and that step requires no verification.
Links
Licensed under GPL-3.0. Questions or suggestions welcome in the comments below, or as an issue on GitHub.
