<p>Having thought some more about it over the last couple of days I believe that it would be nice if the bundle developer could supply more info than just a list of regular expressions.</p>

<p>The case at hand is the insertion of space before/after the capture of the regular expression. The heuristics that we’re currently using (insert before unless no spacing currently exists) is not ideal in two aspects. Firstly, it will not format a selection uniformly unless the developer already had space (or no space) before the capture on every line. Secondly I prefer that the bundle creator has the ability to enforce some standards for aligning the source. For example in CSS the ‘:’ is used for assignments so it looks better (IMO) if they are aligned (I.e. space should be inserted before the capture).</p>

<p>I’m not sure that I fully understand the capabilities of the TextMate preference items but an example solution could be the following.</p>

<p>General: </p>

<pre><code>sourceAlignment = (
    (regexp, spaceBeforeCapture|spaceAfterCapture),
    ...
)</code></pre>

<p>For CSS: </p>

<pre><code>sourceAlignment = (
    (':',  spaceBeforeCapture)
)</code></pre>

<p>What do you think? Would this be possible? </p>

<p>Now for something a bit different. As mentioned earlier I’m very interested in left/right aligning source code as well. To do that properly we would need the following information </p>

<ul>
<li>A regexp with three captures: LHS, delimiter, RHS </li>
<li>For the LHS and RHS captures it should state if it should be left or right aligned</li>
</ul>

<p>If I’m correct and all this info is needed I think that trying to make the align command do this will add to much unnecessary complexity. However, I think it would be awesome to make a general “reformat source” command just as the “align command” that we’re working on now. I think it’s something that is useful in all programming languages and making it easy for the bundle developers (they just have to specify some info in a preference item) will make it more possible that they add support for it :)</p>

<p>For me the alignment and reformatting of the source is quite tightly coupled but I could just create a macro that ran them both on a selection :) </p>

<p>Cheers,
Mads</p>
<br><hr align="left" width="300">
View this message in context: <a href="http://old.nabble.com/Align-Source-tp31636561p31766722.html">Re: Align Source</a><br>
Sent from the <a href="http://old.nabble.com/textmate-dev-f18158.html">textmate-dev mailing list archive</a> at Nabble.com.<br>