Last Updated: February 25, 2016
· 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:


sudo apt-get install googlecl pandoc

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


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.

Say Thanks

4 Responses
Add your response


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 ·

This seems really useful. Thanks for the tip!

over 1 year ago ·

@epicdavi: Thanks, I modified the link!

over 1 year ago ·

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 ·
Filed Under