Adding/removing a prefix and suffix to a piece of text


I was wondering if there is a way of adding and/or removing a set prefix and suffix to a selected piece of text?

For instance selecting a paragraph and adding quotes before and after, although I’m hoping I can set the prefix and suffix myself. My main objective is to surround a piece of text with html tags.



There is nothing like that; but if you are composing HTML in Scrivener, you might be interested in using a tool that lets you extract text from any window and edit it in a different text editor. When you save and close the window the text goes back into Scrivener. QuickCursor is a pretty good example; though unfortunately there is no trial version that I can see—but it supports most of the common HTML friendly text editors out there.

Thanks Ioa!

I don’t write html normally, I’m just trying out a workflow I read about here using multimarkdown to LaTex and because I’m still experimenting I find myself needing these tags to escape Latex quite of. Also because I write quite a bit in TextWrangler (Stata do-files, tex documents and html (sometimes)) and this program can comment/uncomment selections of text and adjusts the comment quotes accordingly I was hoping I could do all my writing in Scrivener. I guess I’ll just have to divide my writing in actual writing and programming.

Thanks for your help!


In that case; do you use inline annotations at all for anything? If not, try this:

Hi Ioa,

No I haven’t, although it looks promising. That is if I understand it correctly… What I think it does is anything that is marked as an inline annotation gets wrapped in html quotes, so all I’d have to do is type my LaTeX, select it and click to make it an inline annotation (of course check the box when compiling). And then during compiling all the LaTeX will be escaped?!

Sounds good, I’ll test it tomorrow as I don’t have everything on this computer, and report back!



Yup! That’s exactly what will happen. Just make sure the HTML option is disabled, otherwise these alternate delimiters will not be used. And you can also use inline annotations like regular formatting, you don’t have to type-then-select; you can be typing along, toggle it on, then back off again when the LaTeX code is entered. The default colour for inline annotations is bright red; since usually it is used for comments; you could try a lighter grey so the code falls into the background. Just put the cursor anywhere in an annotation and use the text colour tool. Once used, it will keep using that colour for new annotations.

Cool! Thanks!


That’s really convenient! And because I can set different enclosing markers for different compiling presets AND it’s a keyboard shortcut, I’m one step closer to doing all my writing in Scrivener!

Now if only it could do syntax highlighting and was apple scriptable… (but let’s not get into that here)

This is a great tip Ioa, and here I was thinking that I read all of them already… silly me.


You’re welcome!

The AppleScript part is definitely planned. Big project, though.