<p>I'm trying to find an editor (or some simple JavaScript - preferably jQuery) that will allow me to edit the contents of a textarea.</p>

<p>I don't want it to be rich text or WYSIWYG; I just want to be able to select a bit of text, click a button/link and have some simple HTML tags that I define put either side of the highlighted text. I also want to be able to insert empty tags at the cursor if no text is selected in the textarea. Essentially, what I'm looking for is similar to the Stack Overflow text editor, but for custom HTML, not Markdown.</p>

<p>What options are there that I could use?</p>

<p>Thanks in advance.</p>

Would something like
this
fit the bill? I think it just uses
```
document.selection
```
to identify where to insert the markup.