elfkaq
Last Updated: February 25, 2016
·
5.434K
· zombiecalypse
38a4bebac658ff3d2da3d5df790a74b8

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.

Say Thanks
Respond

4 Responses
Add your response

15332
Cd65531349640cd84cad55297ae41b7b

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
9b0f7bbf22d65fa2bd23496973c0ba80

This seems really useful. Thanks for the tip!

over 1 year ago ·
16776
38a4bebac658ff3d2da3d5df790a74b8

@epicdavi: Thanks, I modified the link!

over 1 year ago ·
16842
34b7b4e664958afe210fa0d105d92448

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