elfkaq
Last Updated: July 23, 2018
·
9.209K
· zombiecalypse

Editing Google Docs with vim

Google docs is great, but also somewhat annoying in that you can't use your favourite text editor to make changes. Well, not any more.

Google offers GoogleCL to interact with their services on the command line. You could for example use

google docs edit --title "Title of your document" --editor vim

to modify a pure text version of your document with vim. This will lose all your formatting however. You can also modify html with

google docs edit --title "Title of your document" --editor vim --format htm

but this is just horrible to manipulate.

Instead, we can use pandoc to convert from and to just about any format we like.

Now to the gist of it:

Setup

sudo apt-get install googlecl pandoc

Then create somewhere in your path vim-html-markdown with this content:

#!/bin/sh

file=$1
markdown=`tempfile --suffix=.mdown`

# Convert to markdown with pandocs
pandoc "$file" -f html -t markdown -o $markdown

# Edit the markdown file
vim $markdown

# And convert it back to html, which can be uploaded to Google Docs
pandoc $markdown -f markdown -t html -o "$file"

Using it

google docs edit --title "Title of your document" --editor vim-html-markdown --format htm

The file will automatically be uploaded and have the correct formatting.

Modifying it

If you like emacs better, just replace vim with emacs, if you prefer reStructuredText, just replace markdown with rst.

4 Responses
Add your response

15332

Not much development is going on with the Google code repository for googlecl. Here (https://github.com/vinitkumar/googlecl) is a googlecl fork that has some more activity on it.

over 1 year ago ·
15400

This seems really useful. Thanks for the tip!

over 1 year ago ·
16776

@epicdavi: Thanks, I modified the link!

over 1 year ago ·
16842

Seems to not work anymore (at last on OS X, even after installing gdata-python-client from sources):

"Editing documents is not supported for gdata-python-client < 2.0"

over 1 year ago ·