Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I came from the Windows TextMate clone e-texteditor. And in that app, and set to Ruby on Rails bundle while in an .html.erb document, if I was to type Ctrl-Alt-W (equivalent to Ctrl-Shift-W in TextMate), then I get


with the letter "p" in the first pointed brackets highlighted where I can type any text and the other closing brackets' "p" will change accordingly. All is well in both TextMate and in e-texteditor so far. But in e-texteditor, if I then press Tab, the cursor will be moved to the content of these HTML tags like this:


where | represents the cursor. Now I know that Ctrl-Shift-W is supposed to wrap selected text in TextMate, and e-texteditor does that, too! But I find being able to make a pair of HTML tags and tab inside instead of arrow-key myself back in very convenient.

Perhaps there is another shortcut for this?

Just in case I am not being crystal clear already: Ctrl-Shift-W (or another shortcut), when pressed, first generates


with the first 'p' highlighted ready to be changed. Changed or not, when Tab is then pressed, the cursor should go in between these opening and closing HTML tags.

share|improve this question
This has been annoying me for ages. Would love to find out a way to get around this. The only possible workaround I found is to type the content before, and then wrap it, but you've already mentioned. – slhck Dec 30 '11 at 10:47
Nik, you are simply using the wrong shortcut, see my edit to my answer. – romainl Jan 5 '12 at 10:07
up vote 2 down vote accepted


Something was bugging me with your question: I didn't remember having that problem at all but I somehow forgot most of what I once knew about TextMate (switched to Vim a year ago). I just re-licensed TextMate to play around with TM2 so here is your answer:

You are using the "wrong" shortcut.

CtrlShiftW is for wrapping the currently selected text with opening and closing tags.

Since you hit this shortcut without a selection you end up with an empty tag. Because it's designed to work with some pre-existing content it's quite logical that it doesn't provide the ability to edit said content further.

The typical use case is when you paste some raw text from a brief and go through it to add proper HTML formatting.

This shortcut inserting an empty HTML tag pair is something of a mirage. Sure it does that but it's a side effect of not using it properly.

The correct shortcut is Ctrl< which is for inserting opening and closing tags optionally using the current word.

You can use it in two ways:

  1. If you have whitespace on the left of the caret, hit Ctrl< to insert <p></p> with the first p selected. You can either change p to something like h1 and have it mirrored to the closing tag or hit Tab to move the caret between the tags, like that: <p>|</p>.

    Which, I think, is exactly what you want and, actually, what I've always done. Hence my discomfort with your question.

  2. If your caret is positioned just after a word, say span, hit Ctrl< to replace span with <span></span> with the first span selected. You have now the exact same possibilities as with the first method.


My TextMate days are gone now so this solution is probably not the best one but it's very easy to put in practice.

Simply create a snippet with the letter t as trigger and


as content.

When it's done you only have to type t<Tab>p<Tab> then your content.

Obviously, as it is there is a rather important drawback: if you add attributes they will be mirrored to the end tag.

This can be mitigated by adding an extra tab stop:

<${1:tag}${2: }>$0</$1>
share|improve this answer

You could just change the Wrap Selection In Tag snippet from



share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .