Amy Cowen
Freelance Writer
The tag sequences that you type all the time may be so
ingrained in your head that you touch-type the tags, attributes,
and values without thinking about each keystroke. The extra
" and > marks that appear thanks to HomeSite's Auto Completion
feature can quickly dirty your code and cost you extra time
backtracking to clean out rogue marks. As a result, Auto
Completion may be one of the features a Web-savvy coder
turns off as a first-step in customizing her development
environment.
But you might be surprised to find that HomeSite's version
of Auto Completion is a flexible feature which, used smartly,
can save time for newbies and advanced coders alike.
Apples and Oranges
They may sound like similar concepts, but Auto Completion
in HomeSite 4.5 is separate from Tag Completion. You can
customize Auto Completion to offer the benefits of Tag Completion
on a tag-by-tag scenario, but out of the box, these are
very different features. Tag Completion automatically inserts
a closing tag once an opening tag is typed. For example,
as soon as you type <A>, the </A> pops up next
to it, ostensibly saving you the keystrokes needed to complete
the tag and helping to ensure all tags are properly closed.
Auto Completion, on the other hand, looks for a given "trigger"
and then completes it. The trigger may or may not be a "tag."
These triggers are programmable, but a few stock triggers
are available upon installation, including a " every time
a " is used and a # whenever a # appears. These triggers
may remind you of the ones you've encountered in popular
word processing programs, and they might not be triggers
you favor. However, in true HomeSite fashion, the Auto Completion
feature is fully customizable.
Configuring Auto Completion
To access the Auto Completion configuration screen, go to
Settings/Options and select the Auto Completion feature under
Editor.
Figure 1: Auto Completion is controlled through the
Settings panel using the window shown above.
Looking at the Auto Completion window, you see all established
triggers. Those currently active are marked with an x.
Being able to turn select triggers on and off means you
can choose to use Auto Completion without having to use
triggers you find annoying in your own development. It's
not an all-or-nothing scenario. So, you might decide that
having --> appear after you type <!-- is a really
useful trigger that won't get in your way, but you want
to turn off the " trigger. Simply by selecting and deselecting
triggers, you can specify which ones are in use at any given
time.
Tailored Triggers
Creating your own triggers and molding those that exist is
where the potential of Auto Completion really opens up. When
you create or edit a trigger, you specify the following:
- Trigger String - What trigger, when typed, signals that
you want the completion string to appear.
- Completion String - What appears after the trigger is
typed.
- Cursor Position - Whether the cursor should appear after
the completion string, before the completion string, or
whether the string (or a portion of it) should be highlighted.
Specifying the cursor position gives you a lot of control,
and you'll find that the position may differ for each trigger
you configure. For example, in the HTML comment <!--
--> trigger, it makes sense for the cursor to be dropped
in the middle of the tags, or "before" the completion string.
That's where you'll need to insert your text. But for many
of your custom triggers, having the cursor dropped in at
the end will save time and a needless scramble for the "End"
key.
A Sample Site-Specific Trigger
Web developers commonly work with Arial, Helvetica as a FACE=""
string for font tags. However, if you're Unix-aware or working
with Unix clients, you may be in the practice of adding Geneva
to that string, or site guidelines may proscribe a specific
<FONT> string even in combination with master site-wide
style sheets. While snippets or even keyboard shortcuts might
also be in place to offer flexibility for entering code of
this sort, a logical Auto Completion trigger could be built
to handle a commonly-used string like this one: <FONT FACE="geneva,
arial, helvetica" SIZE="2">
Trigger String: <FONT FACE="g
Completion String: eneva, arial, helvetica" SIZE="2">
Cursor Position: After the completion string.
This trigger assumes that when you type <FONT FACE="g
you are in the process of typing the string with the "geneva,arial,helvetica"
face values and a given size. You might decide that using
more letters than "g" in the trigger is necessary for the
trigger to be 100% effective, depending on how commonly
you use other faces that begin with "g" (e.g., Georgia,
Garamond, etc.). Similarly, you may want to use SIZE=""
so that you can fill in the appropriate size, or you might
omit the SIZE attribute all together.
Each trigger you build will depend on your own knowledge
of the sites you work with, applicable site guidelines,
and strings you commonly type. But the above gives you a
look at an easy-to-configure trigger designed to save time
for the coder who routinely types that string many times
a day. A few keystrokes typed, the completion string appears,
and the tag is in place. If you prefer, you can even add
the </FONT> to the completion string, so you don't
have to spend time typing the closing tag.
Code-Savvy Customization
On a ColdFusion site, you may find yourself setting a page-specific
variable at the top of each page, adding a querystring to
URLs you code, or performing other repetitive tasks that could
be streamlined with Auto Completion. If you aren't using the
less-malleable Tag Completion, you might want to beef up your
Auto Completion list to include some closing tags like </CFLOOP>,
</CFOUTPUT>, and so on. And because you can easily activate
and deactivate triggers, you can set triggers up for specific
projects or maintenance gigs and deactivate them when you're
done so that they don't unexpectedly get in your way. Later,
if you return to work on that site, it's simple to turn them
on again. Just as snippets have become invaluable for many
HomeSite developers, with a bit of careful thought about your
coding practices, you can craft Auto Completion triggers that
will become a welcome part of your coding environment.