# Toolbar button to reformat textarea

**URL:** https://meta.discourse.org/t/toolbar-button-to-reformat-textarea/54673
**Category:** Development
**Created:** [December 22, 2016, 9:53pm UTC](https://meta.discourse.org/t/toolbar-button-to-reformat-textarea/54673 "2016-12-22T21:53:36Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kgish](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kgish/32/121131_2.png) [@kgish](https://meta.discourse.org/u/kgish)
#### Post date: [December 22, 2016, 9:53pm UTC](https://meta.discourse.org/t/toolbar-button-to-reformat-textarea/54673/1 "2016-12-22T21:53:36Z")

</div>

I’m trying to create a toolbar button that will take the current contents of the textarea, scan the text and reformat it, thereby completely replacing the contents with new text.

The API only provides `e.addText()` and `e.selectText()` but no way to select and replace.

Am I overlooking something, or is there a more obvious way of achieving this?

---

<div class="post-metadata">

### Author: ![kgish](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kgish/32/121131_2.png) [@kgish](https://meta.discourse.org/u/kgish)
#### Post date: [December 23, 2016, 1:12pm UTC](https://meta.discourse.org/t/toolbar-button-to-reformat-textarea/54673/2 "2016-12-23T13:12:00Z")

</div>

Here is my [Pull Request](https://github.com/discourse/discourse/pull/4621) to get this working.
