Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Make Gist editor automatically resize based on content using a TamperMonkey script
// ==UserScript==
// @name gist-editor-resize-userscript
// @namespace
// @version 0.1
// @description Automatically resize the gist editor for easier editing.
// @match http*://*
// @copyright 2013+ Joel Day -
// ==/UserScript==
var textareas = document.querySelectorAll('textarea.file_contents');
var span = document.createElement('div'); = "hidden";
$('textarea.file-contents').keyup(function(){ = this.offsetWidth + 'px'; =;
span.innerText = this.value; = span.offsetHeight + 'px';
Copy link

NeWbLt123 commented Jul 10, 2014

Is this still supposed to work ?
I'm getting ERROR: Execution of script 'gist-editor-resize-userscript' failed! Cannot read property 'getDocument' of undefined


Copy link

jm3 commented Sep 4, 2014

@NeWbLt123 ja, same

Copy link

Dayjo commented Sep 23, 2014

@jm3 @NeWbLt123 - I've updated this to now at least support the normal textarea style editor (not Ace yet)

Copy link

dragon788 commented Jun 22, 2016

Any chance on getting this updated for Ace, or is it just a pain in the 'ace'?

Copy link

Artistan commented Nov 30, 2017

Recommend setting your namespace to
So people can come back to this for updates 👍

FYI ... errror

ERROR: Execution of script 'gist-editor-resize-userscript' failed! $ is not a function

this may be a relevant reference for a better solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment