Adding Links
Creating hyperlinks (<a>
elements) is an essential task when writing HTML. TypeMetal has some special features that make wiring links fast and easy.
A Dedicated “Create Link” Command
Sure, you can autocomplete an “<a>
” element pretty fast. But why use more keystrokes than you have to? A simple Command+K triggers the Structure → Create Link menu item. The result is the same as when completing an <a>
element, except: If there’s an existing <a>
element that encloses the selection or insertion point, TypeMetal opens the attribute editor for the existing <a>
instead, focusing its “href
” attribute for editing. Thus, you can use Command+K to view and edit existing links, as well as creating new links.
You can press Command+K in the attribute editor to close it. Pressing Return or Esc with the focus in the attribute editor’s search field also closes the attribute editor.
For quickly choosing and linking to another local file, TypeMetal also offers the Command+Option+K keyboard shortcut (Structure → Create Link to File…), that instantly prompts you for the destination file, and creates the link as soon as you’ve chosen it.
URL Autocompletion
The editor module for a URL-valued attribute (such as an <a>
element’s “href
”) provides autocompletion to URLs TypeMetal knows about — so all you usually need to do is type several characters of the file name or URL you want. The autocompletion list includes:
- URLs that you’ve recently copied to the pasteboard — so you can copy several URLs of interest from a Web browser window, and have them all available for pasting into an HTML document the next time you return to TypeMetal. This is a lot more efficient than having to switch back and forth between a browser window and a TypeMetal document window each time you want to copy a link.
- files in folder trees that TypeMetal has open in association with your HTML file. This makes it quick and easy to find target .html files in the same folder or nearby folders.
- URLs that are already referenced in your document — so once you have one link to a given destination, it’s easy to create another.
If you’ve unchecked “Show URL suggestions automatically” in TypeMetal’s General settings, you’ll need to type ⌘↓ while editing a URL attribute to get TypeMetal to show the URL autocompletion list.
TypeMetal can only gather recent URLs from the pasteboard while it is running — so be sure to launch TypeMetal before you go on a link-gathering expedition. TypeMetal does remember gathered links across launches (discarding old URLs only when it has gathered more than 100), so you can quit it without losing this handy cache.
A link you copy to the pasteboard can include title text, in addition to a URL. To get a titled link, right-click a hyperlink in a Web browser window (e.g. Safari) and choose “Copy Link”. The link will carry the text that labels it, in addition to its URL, and that title will serve as the <a>
element’s content if you paste the titled link into a TypeMetal document.
You can also copy a URL from a Web browser’s address (location) field, but such links don’t usually carry a title. So when you have a choice, you may prefer to copy the link to a destination from a page that references it. This will save you a bit of typing.
URL Autofill
TypeMetal also makes an initial guess at the desired link target when you create an <a>
element.
If the pasteboard contains a URL, TypeMetal initializes the link’s “href
” attribute to point to the specified destination. Otherwise, TypeMetal chooses the URL it most recently observed on the pasteboard.
If TypeMetal’s guess is wrong, of course, you’re free to edit the href attribute to point the link to what you actually want. TypeMetal automatically opens the attribute editor for a newly created <a>
element, and focuses the “href
” attribute so you’re ready to type another value if desired.
URL Choosing
You can also click the (∞) button in a URL attribute value module, to choose a local file to link to using a standard Open sheet.
URL Following
Click the (→) button in a URL attribute value module to open the link. Links to .html files will open in TypeMetal. “http://” links will open in your default Web browser. Links to other kinds of local files will open in the appropriate application, according to the file and its type.
Other Ways to Insert Links
You can drag an .html file into a TypeMetal document — either from the Finder, or from the document icon at the top of another TypeMetal HTML File Window. TypeMetal drops an <a>
element into the document that points to the dropped file, and gives the link some selected initial label text that you can then replace just by typing.