Question

Caveat: I'm relatively new to coding as well as TextMate, so apologies if there is an obvious answer I'm missing here.

I do a lot of HTML/CSS markup, there are certain patterns that I use a lot, for example, forms, navigation menus etc. What I would like is a way to store those patterns and insert them quickly when I need them.

Is there a way to do this using TextMate?

Was it helpful?

Solution

You can do this very easily in TextMate using Snippets. Just add a new snippet in the bundle editor, and set up how you want to trigger it. You can set a key shortcut, or have it pop up when you hit Tab after a certain word/pattern.

There are many things you can do with them—in your case, it would probably be very useful to set so-called "placeholders" in your snippets, which are the parts that change every time (e.g. the names of the fields in the form). Then, as soon as you insert the snippet, you can hit Tab to move between these.

OTHER TIPS

Along with the links provided above, I think you'll find this screencast useful. It gives a run through of some of the tools TextMate's HTML bundle already provides.

It's probably slightly off-topic though, but worth a look nonetheless.

As mentioned prior snippets are what you are looking for.

For reference look here: http://manual.macromates.com/en/snippets
http://screenflicker.com/mike/code/div-snippets/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top