Using Google Docs, when I click Insert > Bookmark I create a bookmark (duh!) in that place of the document, kind of a <a name="here">cursor</a>.

I have a few of these bookmarks in a document. I'd like to edit the document in an external editor (e.g., Notepad++) and paste it back to Google Docs, but then I face the problem of having to regenerate the bookmarks by hand.

Is there a way to indicate to the docs editor that I want a bookmark in a specific place? I'm thinking of something like

== here ==  

and then


in Wikimedia style.

  • I'd offer a bounty if I were given the option
    – malarres
    Oct 23, 2014 at 7:10
  • doing that, now that I can :)
    – malarres
    Jan 9, 2015 at 10:49
  • This isn't a direct answer to your question, but a work-around: Create and maintain the documents in a plaintext format and use a third-party Google Drive application to edit them. I use Draft (draftin.com) for plain text files when I want collaborators and version control, and StackEdit (stackedit.io) for markdown documents with no special collaboration requirements. Jan 9, 2015 at 17:08

1 Answer 1


The short answer is: yes. Hurray!

The medium-length answer is: yes, if have mad skillz. Aww, shucks.

A more full answer

Through Google Apps Script, Google Docs is amazingly extensible. The lynchpin function you are seeking is aptly named addBookmark() (class description here). The function requires a passed value, however, and that is what will require some creativity.

In Pseudo-code, something like the following might work:

Prior to uploading the document to Google, designate the bookmarks you want with super-special-awesome markup that doesn't interfere with anything. Per your suggestion, let's pretend we know that enclosing in two equal signs will not cause you problems, so == Special text to bookmark ==. Upload the document. Run your script.

The script:

  1. Starting at the top of the file, search the text of the document for a string pattern that matches == [any text] ==
  2. When matching string is found, get the Position (class description here) of the text
  3. Use Position and run addBookmark(Position)
  4. Continue with search of text until end of file
  5. Announce the end of the script execution

For a competent programmer, this is not a particularly difficult task. Even though I can conceptualize the pseudo-code and read the class descriptions, if I tried to write this, I would certainly gain more gray hair.

Good luck!

  • 1
    Thanks a lot! I will try that (and gain some gray-to-white hair in the process :)
    – malarres
    Jan 10, 2015 at 8:57
  • 1
    I'm giving the +50 to you altough I didn't find the time to try it. Thanks for the reply (it looks promising)
    – malarres
    Jan 15, 2015 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.