Quotes but with Angle Brackets

Whenever I select text and type the left angle bracket, I expect to have this: (assume % is a cursor and [] is selected text)
<%>
[thing 1]
[thing 2]
</%>
But instead, I get this:
<%
It would also be nice if when this does happen with one line of HTML, it would automatically detect whether to do it inline or to put it at the top and bottom (like the first example). Maybe it could detect this by whether or not it has display: inline under CSS.
(don’t forget to vote!)