6

Is there a way to make TextMate automatically add a closing HTML tag when I type the opening one? Something like what Notepad++ does under Windows/Linux, or MS Visual Studio.

I mean WITHOUT any shortcuts? So I just type "<body>" and it adds "</body>" and puts the cursor back in between. Without any "Ctrl + Shift + Option + Whatever" black magic.

Or a TextMate alternative maybe?

PS. Mac OS is just one of the many OS'es I work in, so I don't want to litter my brain with any shortcuts...

Alex from Jitbit
  • 53,710
  • 19
  • 160
  • 149

3 Answers3

11

No, you can't. The simplest thing you could do for closing tags is to type some opening tag with it's contents <div>Some text and then hit Command + Option + Dot to close the most recent unclosed tag. This involves a shortcut but it is easy to remember.

Simon Perepelitsa
  • 20,350
  • 8
  • 55
  • 74
1

One alternative, which may or may not suit how you code, is to hit ctrl+shift+W (wrap selection). With nothing selected you'll get <p></p>, with the 'p' highlighted so you can overtype with your desired tag name.

I personally prefer the cmd+option+. shortcut already mentioned.

Credit to http://www.456bereastreet.com/archive/200811/textmate_productivity_tips/

spume
  • 1,704
  • 1
  • 14
  • 19
1

Typing e.g. body and then pressing TAB will complete the tag.

s.m.
  • 7,895
  • 2
  • 38
  • 46