Balance Jr 2.0 for TextMate ScreenCast!

by Thomas Aylott Sat, 06 May 2006 19:40:00 GMT

The following is not exactly a transcript of the audio from my new Balance Jr 2.0 command screencast.

Balance Junior the 2nd Screencast

Balance Junior the 2nd Screencast

Download

tAylott_subtleGradient.tmbundle.zip

Or as always, you can grab all my stuff from my subversion repository. http://textmate.svn.subtlegradient.com/

Hello internet people

Thomas Aylott (aka subtleGradient) here to show you the latest edition of my Balance Jr command.

I noticed that there were a number of problems with the original that have always bugged me.

For example:

THIS ONE!!!! Where it selects the contents of string as well as the text between strings. Bleah, horrible.

Also, Duane Johnson released his snazzy Jump commands.

Here, have a goosee and the new regex. Note the lovely use of comments to disambiguate.

Let me show you a few things you can do with it.

Ok, there’s some HTML.

Balance Jr Foreword grabs stuff in big chunks When the caret is outside a tag it’ll grab the entire next tag. When the caret is INside a tag, it’ll grab the entire next attribute value pair, or whatever biggest thing it can get ahold of

Balance Jr Backwards is much more fine tuned As you can see.

for example, You can place the caret inside an html attribute’s value string, hit Balance Jr back and it selects the contents of the string, Hit it again and it’ll select outward until it grabs the entire tag.

ok! While we’re here…

Here’s my “add an HTML attribute” command. And Here’s Duane’s “Jump Next” command in action.

o…k

There are two built-in commands in the latest editions of TextMate EDIT/ SELECT/ “current scope” and EDIT/ SELECT/ “enclosing brackets”

note that both of these grab the brackets at the ends. While Balance Jr only grabs the innards!

Welp, that about wraps it up. goodnight everybody!

(?#

HTML tags that don't contain text
)<(\w+)[^>]*>[^<]*</\1>|(?#

The contents of various other forms of Embedded source
)(?<=(<%@\s|<%#\s|<%=\s))[^%]*(?=\s%>)|(?#

The contents of Embedded source
)(?<=<%\s)[^%]*(?=\s%>)|(?#

HTML Comments
)(?<=<!--\s)[^->]*(?=\s-->)|(?#

HTML Attribute name
)\b[\w-]+\b(?=\s*=)|(?#

HTML Attribute name value pair
)\s\b[\w-]+\b=\"[^\"]*\"|(?#

HTML Compatible "String Double"
)(?<=\")[^\"\n<>]*(?=\")|(?#

'String Single'
)(?<=')[^'\n]*(?=')|(?#

[Square Brackets]
)(?<=\[)[^\[\]]*(?=\])|(?#

{Curly Brackets}
)(?<={)[^{}]*(?=})|(?#

>Text Inside HTML Tag</
)(?<=[^/]>)[^><]*(?=</)|(?#

Hex Colors #AABBCC
)(?<=#)[0-9a-fA-F]{3,6}|(?#

Number
)(?<!\d)\d+(?:\.\d+)?(?!=\d)|(?#

@variables $variables !etc
)[@$!]\w+\b|(?#

/* Contents of Comment Blocks */
)(?<=/\*).*(?=\*/)|(?#

Comma Delimitated
)(?<=[\(,:])[^\(\),\n]*(?=[\),;])|(?#

CSS Attribute Values
)(?<=:)[^;}]*(?=;)|(?#

Closed xHTML Tags
)<[^>]*/>|(?#

Placer for adding HTML Attribute Values
)(?<=\")(?=(>|/>| />))|(?#

HTML Tags
)<[^>]*>|(?#

"String Double"
)(?<=\")[^\"\n]*(?=\")|(?#

Space and the end of the line
)\s+$|(?#

JS function names and variables
)\b[a-zA-Z][\w\.]*\b(?=(\[|\s*(&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|/=|%=|\+=|\-=|&=|\^=|\()))|(?#

The End :)subtleGradient

RSS feed for this post |Trackback from your site |Add your comment

  1. if you do (?x) then you can use line breaks and comments from that point

    Cool. I guess I have to rewrite it now. ;)

    Thomas Aylott about 1 hour
  2. I used Brad Choate’s awesome textmate to html conversion stuff to render the source as HTML using my Brilliance Black TextMate Theme

  3. Nice work! I learn new stuff all the time from you :) I didn’t know you could put comments inside of a regexp!

  4. Me neither. Then I read some more at regularexpressions.info . That place it wonderful for learning regex.

    Also there’s the official Oniguruma reference document . I should really read that one again.

  5. I did not understand how you do this trick with changing the opening html tag with automatically simultaniously changing its appropiate closing tag. Which short cut is this?

  6. You’ll need to grab Duane’s Stuff to do that.

    Or you can get my version of his stuff . He may have updated it since I last got my copy.