<!-- thumbnail: http://i.imgur.com/FMih93I.png --> <!-- version: 1.0 --> <!-- tag: script --> <!-- excerpt: A Userscript to add line numbers to code blocks --> ## Screenshot > [![Dark mode code block with prefixed line numbers][1]][1] > [![Light mode code block with prefixed line numbers][2]][2] ## About I've always wanted to have line numbers prefixed in code blocks on questions / answers. This userscript takes the code-blocks on the page, and inserts line numbers. It will look at the length of the code block to determine the required additional padding, so a short code-block wouldn't have too much whitespace to allow for 3-digit line numbers. ### Download **[Download Link](https://github.com/Cerbrus/MD.Misc.Snippets/blob/master/userscripts/stack-exchange-line-numbers.cerbrus.user.js)** If you don't have a userscript client, you'll need one. [TamperMonkey][3] for Chrome or [GreaseMonkey][4] for FireFox are good options. ## Contact The best way is to leave a [Github Issue][5] for feature reqs, issues, and anything related to the userscript. ## Code The code is on [Github][6] [1]: https://i.sstatic.net/sdC3G.png [2]: https://i.sstatic.net/ffmmE.png [3]: https://tampermonkey.net [4]: https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/ [5]: https://github.com/Cerbrus/MD.Misc.Snippets/issues [6]: https://github.com/Cerbrus/MD.Misc.Snippets/tree/master/userscripts