How can I add opening and closing HTML tags to a line of text?

I need to hand-convert a text document into HTML, and I thought I might save myself some time with Text Blaze, but I can't quite figure it out.

I want to be be able to put my cursor at the beginning of a line like this:

Hello, World!

and then type a shortcut that turns it into:

< span > Hello, World! </ span >

When I'm manually typing, I can jump to the end of the line by holding down the Command key and pressing the right arrow. So I tried to teach TB: < span >{key: cmd-rightarrow}< /span >

But instead of jumping all the way to the end of the line, TB just moves one character to the right, so I end up with:

< span >H< /span > ello, World!

Obviously, less than ideal! Does anyone have a suggestion for me? Thanks!

I know I have extra space in the < span > tags -- otherwise this forum software takes them seriously!

Hi @Tara_Harwood, welcome to the forum!

Here's a simple way to do it:


All you need to do is:

  • highlight the piece of text you want inserted inside the span
  • cut it using cmd+x
  • insert your snippet in the place where the text belongs.

That's the basic way. But I sense you're an adventurous soul in search of arcane Text Blaze secrets! :grin:

So here's something a tad more snazzy:

<{formtext: name=tag; default=span}>{clipboard}</{=tag} >

Now, you can customize the tag whenever you insert the snippet. I set the default value to span because I got the impression that it's what you use most frequently, but you can change the default setting to whatever you want.

In the closing tag, I linked to the variable name of the text field. So, anything you write in that text field gets replicated at the end.

Oh wait, you want more? OK :grin:

<{formmenu: name=tag; default=span, div, h1, h2, h3}>{clipboard}</{=tag} >

Same story as the previous example, but using a drop down menu. Again, feel free to change the default and add/remove menu items as required.

There's also a way to break text up into linebreaks and put tags around every part, but it's a bit more involved and I'm writing this on my phone :blush:

If you're interested in that method, let me know and I'll share it as soon as I get to my computer.

PS. You can grab all of the examples I shared with you by clicking the "copy to Text Blaze" button in the top right of the example window.

Hope this helps!