Surround selected text with HTML comment tags

Help with writing and playing macros

Surround selected text with HTML comment tags

Postby kencl » Sat Nov 11, 2006 2:05 pm

Here's a simple macro I use all the time. It surrounds the currently selected text with HTML comment tags:

Code: Select all
InsertMode
ColumnModeOff
HexOff
UnixReOff
Find "^s"
Replace All SelectText "<!-- ^s -->"


I got the idea from ColdFusion Studio. Very handy. You can see how easy it would be to convert it to, eg JavaScript blockquotes. Just replace the last line with:

Code: Select all
Replace All SelectText "/* ^s */"
User avatar
kencl
Newbie
 
Posts: 6
Joined: Thu Jul 22, 2004 11:00 pm

Re: Surround selected text with HTML comment tags

Postby mrainey56 » Sat Nov 11, 2006 3:39 pm

That's a good example of a tiny macro that can make a huge difference!
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Surround selected text with HTML comment tags

Postby Mofi » Sat Nov 11, 2006 6:20 pm

Just want to tell you and all other interested users that inserting a text at start and end of a selection can be also done with

  • HTML Toolbar commands which can be customized at Configuration - Toolbars / Menus - HTML Toolbar
  • templates like /* [$replace$]^ */ which can be configured at Advanced - Display/Modify Templates
  • tags via the tag list view (View - Views/Lists - Tag List) which can be modified by right clicking into the tag list view and select Modify Tags
Advantage of the macro is that the selection will remain after execution.

Advantage of the other methods is that it will not work only on a selection. The start and end text will be also inserted without selection and the cursor is placed between them depending on the definition.

I use templates for most of such replacements. The tag file is used for many other often used strings. 4 template examples:

  1. Template "Convert to URL"
    <a href="^[$replace$]">[$replace$]</a>
  2. Template "Convert to mail URL"
    <a href="mailto:[$replace$]">^[$replace$]</a>
  3. Template "Date International"
    [DATE_USER]yyyy'-'MM'-'dd[DATE_USER_END]
  4. Template "Date German"
    [DATE_USER]dd'.'MM'.'yyyy[DATE_USER_END]
The last two templates are also used from within a macro to modify the date in the HTML head (international format) and in the document head (German format) of my HTML files.

For more informations about templates and tags see

Templates and tags are really very helpful and easy to use, but not very good documented and so most users don't know about it.

A look on the Downloads - Extras page on this site is also a good idea. There are some useful files too.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Macros