# Add button to select all text in a preformatted block

**URL:** <https://meta.discourse.org/t/add-button-to-select-all-text-in-a-preformatted-block/30878>\
**Category:** Feature\
**Tags:** completed\
**Created:** [July 8, 2015, 2:35am UTC](https://meta.discourse.org/t/add-button-to-select-all-text-in-a-preformatted-block/30878 "2015-07-08T02:35:22Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![wesochuck](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wesochuck/32/108706_2.png) [@wesochuck](https://meta.discourse.org/u/wesochuck)\
**Post date:** [July 8, 2015, 2:35am UTC](https://meta.discourse.org/t/add-button-to-select-all-text-in-a-preformatted-block/30878/1 "2015-07-08T02:35:22Z")

</div>

We’re moving our internal knowledge base over to Discourse and one thing we’re finding difficult is working with the topics that have a lot of code (usually SQL) in them.

We wrap the code blocks using the preformatted text option to preserve link breaks and enable code highlighting, but then when we need to use the code, the copy/paste is a bit cumbersome due to the horizontal scrolling.

I know that adding an actual copy to clipboard button is a bad idea due to security concerns and a requirement for flash, but would it be possible to add a “select” button that would _select all_ the text in a preformatted text box?

This seems like it might be possible to do according to:

> <https://stackoverflow.com/questions/1173194/select-all-div-text-with-single-mouse-click>

Putting the button in the lower right hand corner of the preformatted block seems like a nice way to handle the UI (replace COPY with SELECT in this example):

 ![](https://global.discourse-cdn.com/meta/original/4X/1/3/a/13af02858377408eb2b5c82f1c9273719b9fecb2.png)

---

_[View the full topic](https://meta.discourse.org/t/add-button-to-select-all-text-in-a-preformatted-block/30878)._
