Haven't seen this on the list:
http://nickgravgaard.com/elastictabstops/
The idea sounds quite interesting IMHO. Any chances to see something like this in a future TextMate release? :)
Christian
On 4/7/2006, at 8:58, Christian Bogen wrote:
[...] The idea sounds quite interesting IMHO. Any chances to see something like this in a future TextMate release? :)
I got a few personal emails about it and one ticket request :)
Here’s my canned reply:
Indeed it is interesting. I do think there would be too big a compatibility problem with actually saving such files, since all renderings of the file (cat it in terminal, paste it in an email, on the web, etc.) would be wrong -- and it’s not easily fixable, e.g. by piping the text through something like expand, which would normally fix presenting a file with the wrong tab size.
But the actual editing mode might be useful to have. I’ll need to give it some further thoughts.
I have considered expanding the current smart tab behavior so that if tab is pressed while at the end of the line (rather than start) it would insert enough padding to align with what’s on the line above -- I am however skeptical about this going to “feel right” instead of just getting in the way. But it’s worth doing some prototyping.
On 4 Jul 2006, at 08:09, Allan Odgaard wrote:
On 4/7/2006, at 8:58, Christian Bogen wrote:
[...] The idea sounds quite interesting IMHO. Any chances to see something like this in a future TextMate release? :)
I got a few personal emails about it and one ticket request :)
Here’s my canned reply:
Indeed it is interesting. I do think there would be too big a compatibility problem with actually saving such files, since all renderings of the file (cat it in terminal, paste it in an email, on the web, etc.) would be wrong -- and it’s not easily fixable, e.g. by piping the text through something like expand, which would normally fix presenting a file with the wrong tab size.
But the actual editing mode might be useful to have. I’ll need to give it some further thoughts.
I'd like to see this as an editing mode, automatically managing real tabs/spaces for me.
I use tabs for aligning assignment blocks, and so often find myself going back up to add extra tabs when the left side of the assignments becomes longer than I expected. Example (using 4 spaces for a tab here):
$a = 'A'; $bb = 'B'; $ccc = 'C';
If I were to enter a forth line with a really long variable name, I'd *love* for the behaviour to be result in:
$a = 'A'; $bb = 'B'; $ccc = 'C'; $really_long_name = 'foo';
.. but for that to be done with real tabs. I think the suggested convention of using a blank line to clear the alignment is a good one.
Not sure if that's useful input or not, but there you have it :)
drew.
Drew,
if you use column selection you can easily add some more tabs to your "too short" lines… ;)
Dan
On 4 Jul 2006, at 10:47, Daniel Käsmayr wrote:
if you use column selection you can easily add some more tabs to your "too short" lines… ;)
Oh, I use column selection all the time. It's one of those features you never knew you wanted (and proof why software design isn't about just listening to what users say they want).
I was going to say that the only downside to column selection is that it requires the use of the mouse - but you've prompted me to RTFM and I now know how to make column selections with the keyboard too. So thanks for that :)
drew.
On 4/7/2006, at 11:41, Drew McLellan wrote:
I use tabs for aligning assignment blocks [...]
As I just posted to the blog, in addition to column typing there is also a third party command which can align them for you:
http://random-dreams.org/2006/05/fun-with-textmate-align-equals- in.html
On Tue, Jul 04, 2006 at 10:41:25AM +0100, Drew McLellan wrote:
I'd like to see this as an editing mode, automatically managing real tabs/spaces for me.
I use tabs for aligning assignment blocks, and so often find myself going back up to add extra tabs when the left side of the assignments becomes longer than I expected. Example (using 4 spaces for a tab here):
$a = 'A'; $bb = 'B'; $ccc = 'C';
If I were to enter a forth line with a really long variable name, I'd *love* for the behaviour to be result in:
$a = 'A'; $bb = 'B'; $ccc = 'C'; $really_long_name = 'foo';
.. but for that to be done with real tabs. I think the suggested convention of using a blank line to clear the alignment is a good one.
I wonder if this behavior could be done with a very fancy "Insert as Snippet" command, similar to the technique Duane used to implement his MASC editing[1]. In the example above if you could magically convert the text:
$a = 'A'; $bb = 'B'; $ccc = 'C';
into the snippet:
$a${1/(.{1,4}$|.)/ /g} = 'A'; $bb${1/(.{1,4}$|.)/ /g} = 'B'; $ccc${1/(.{1,4}$|.)/ /g}= 'C'; ${1:$variable} = '${2:value}';
Then you get auto-expanding columns. (Try pasting the above code into a dummy snippet and then inserting that snippet to try it out.) The magic number 4 in the '.{1,4}' construct is the length of the longest value in that "field". A command to generate this snippet would need to:
* Parse the input text into fields/tab-stops. * Find the longest length of each field/tab-stop. * Generate placeholder substitutions for each field along the lines of what's given above. * Return that text as a snippet.
I'm not sure how well the regex substitution would perform if, say, every one of the 1000 lines in your file had several fields per line.
This replacement technique also has another annoyance: if the text you're adding is shorter than the current field, the new field won't get padded to the correct width. I'm not sure how to trick a regex into *adding* characters. You could do something like:
${1/(...)|(..)|(.)/(1? )(2? )(3? )/}
but if your field is 30 characters wide you'd have to cover the 29 cases where your new entry is shorter than that.
I also have no idea how you'd handle things like fields that spill over onto multiple lines. Maybe this'll inspire somebody, though.
[1]: http://blog.inquirylabs.com/2006/04/25/textmate-snippets-like-youve-never-se...