Hi there -
loving TextMate in general, but really want one feature I've had from several editors in the past (e.g. Scintilla, Eclipse):
For indenting/dedenting, commenting/uncommenting, duplicating, deleting with a selection, I'd like TextMate to work on the full lines rather than the exact selection.
So if you make a selection of several lines starting from the middle of one and finishing in the middle of one, and then do an operation like commenting
http://img.skitch.com/20101105-c3t72pnsp98jp71d6xfkxjwfnq.png
Then the result wouldn't be as currently (that the comment delimiter is placed in the middle of the line, generating syntactically incorrect code)
http://img.skitch.com/20101105-r4u82qkcxr4germwqkcjgp9wa1.png
But instead comment as if I had selected the whole lines.
http://img.skitch.com/20101105-djej4cyhrkkckp2jjq1jeaeu38.png
I'd like indent/dedent, duplicate and delete to work similarly.
Is there a way to make this happen? Can I "decorate' those commands somehow to select the relevant lines first... Or would I just have to rewrite those particular features (for each bundle I want them to happen in? )
(Hoping the screenshots I took make it into the mail).
thanks in advance
Tim
http://red56.co.uk http://tim.teamportfolios.com/ tim@red56.co.uk
On 5 November 2010 11:30, Tim Diggins tim@red56.co.uk wrote:
<snip> ... forcing selection to full lines ...
Is there a way to make this happen? Can I "decorate' those commands somehow
to select the relevant lines first... Or would I just have to rewrite those particular features (for each bundle I want them to happen in? )
thanks in advance
The commands could be rewritten, for sure, but wouldn't it be easier to teach yourself to select full lines when you need it? I usually make such selections by triple-clicking the first line to select it, and then dragging which will now continue to select full lines. You can also click and drag in the line number gutter to select full lines.
I primarily use the keyboard. If I want to "teach myself" a different way of interacting, I'd go for vim!!
On Fri, Nov 5, 2010 at 12:01 PM, Sven Axelsson sven.axelsson@gmail.comwrote:
On 5 November 2010 11:30, Tim Diggins tim@red56.co.uk wrote:
<snip> ... forcing selection to full lines ...
Is there a way to make this happen? Can I "decorate' those commands somehow
to select the relevant lines first... Or would I just have to rewrite those particular features (for each bundle I want them to happen in? )
thanks in advance
The commands could be rewritten, for sure, but wouldn't it be easier to teach yourself to select full lines when you need it? I usually make such selections by triple-clicking the first line to select it, and then dragging which will now continue to select full lines. You can also click and drag in the line number gutter to select full lines.
-- Sven Axelsson ++++++++++[>++++++++++>+++++++++++>++++++++++>++++++
++++<<<<<-]>++++.+.++++.>+++++.>+.<<-.>>+.>++++.<<.
+++.>-.<<++.>>----.<++.>>>++++++.<<<<.>>++++.<----.
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On 5 November 2010 13:34, Tim Diggins tim@red56.co.uk wrote:
I primarily use the keyboard. If I want to "teach myself" a different way of interacting, I'd go for vim!!
OK, keyboard it is. How about just hitting Shift+Cmd+L to extend the selection to full lines? That's not too bad, right?
Hi,
for such cases I wrote the TMTOOLS plugin
http://email.eva.mpg.de/~bibiko/downloads/textmate/
help:
http://email.eva.mpg.de/~bibiko/downloads/textmate/tmtoolshelp.html
If you install it (on your own risk ;) then you can write this tmcommand and bind it to any short-cut:
Save: nothing
Command:
if [ ${#TM_SELECTED_TEXT} -gt 0 ]; then "$TMTOOLS" set caretTo "{line=$TM_INPUT_START_LINE;column=0;}" if [ $TM_LINE_NUMBER -eq $TM_INPUT_START_LINE ]; then "$TMTOOLS" move selectionBy "{line=0;column=$((${#TM_SELECTED_TEXT} + $TM_COLUMN_NUMBER - 1));}" else "$TMTOOLS" move selectionBy "{line=$(($TM_LINE_NUMBER-$TM_INPUT_START_LINE));column=$(($TM_COLUMN_NUMBER - 1));}" fi fi
"$TMTOOLS" call command '{name="Comment Line / Selection";}'
Input: nothing
Output: Show as Tool Tip
Have fun,
--Hans
On Nov 5, 2010, at 9:59 AM, Sven Axelsson wrote:
OK, keyboard it is. How about just hitting Shift+Cmd+L to extend the selection to full lines? That's not too bad, right?
I use that all the time to select the current line. I didn't know it could be used to fix a sloppy selection like that. Thanks for the tip!
Yeah, great tip - I'd missed that very useful key command.
However the more I think about it, the more I think that the current behaviour with (what you might call sloppy multi-line selection), for indent/dedent and comment/uncomment is not very helpful. Indeed I can't understand what need the current behaviour serves (i.e. should be treated as a bug).
On Fri, Nov 5, 2010 at 2:46 PM, Rob McBroom mailinglist0@skurfer.comwrote:
On Nov 5, 2010, at 9:59 AM, Sven Axelsson wrote:
OK, keyboard it is. How about just hitting Shift+Cmd+L to extend the selection to full lines? That's not too bad, right?
I use that all the time to select the current line. I didn't know it could be used to fix a sloppy selection like that. Thanks for the tip!
-- Rob McBroom http://www.skurfer.com/
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On Nov 5, 2010, at 9:50 AM, Tim Diggins wrote:
Yeah, great tip - I'd missed that very useful key command.
However the more I think about it, the more I think that the current behaviour with (what you might call sloppy multi-line selection), for indent/dedent and comment/uncomment is not very helpful. Indeed I can't understand what need the current behaviour serves (i.e. should be treated as a bug).
Why? Triple-click extend is standard behavior on OS X. Does that not work for you?
Gerd
On Nov 5, 2010, at 10:50 AM, Tim Diggins wrote:
However the more I think about it, the more I think that the current behaviour with (what you might call sloppy multi-line selection), for indent/dedent and comment/uncomment is not very helpful. Indeed I can't understand what need the current behaviour serves (i.e. should be treated as a bug).
I comment selections now and then (usually at the end of a line). I agree that use cases for doing this on multiple-line selections are less common, but even there it can come in handy. CSS is a prime example, since it only has block style commenting.
.one { padding: 0em; } .two { padding: 1em; }
If I wanted to comment out the “one” class and selected the first three lines, I would end up breaking the “two” class.
/*.one { padding: 0em; } */.two { padding: 1em; }
So I get around this by selecting everything but the newline.
Oh, ok - I can see that use-case. Always interesting how different people use software differently.
Thanks for all the responses.
On Fri, Nov 5, 2010 at 3:11 PM, Rob McBroom mailinglist0@skurfer.comwrote:
On Nov 5, 2010, at 10:50 AM, Tim Diggins wrote:
However the more I think about it, the more I think that the current behaviour with (what you might call sloppy multi-line selection), for indent/dedent and comment/uncomment is not very helpful. Indeed I can't understand what need the current behaviour serves (i.e. should be treated as a bug).
I comment selections now and then (usually at the end of a line). I agree that use cases for doing this on multiple-line selections are less common, but even there it can come in handy. CSS is a prime example, since it only has block style commenting.
.one { padding: 0em; } .two { padding: 1em; }
If I wanted to comment out the “one” class and selected the first three lines, I would end up breaking the “two” class.
/*.one { padding: 0em; } */.two { padding: 1em; }
So I get around this by selecting everything but the newline.
--
Rob McBroom http://www.skurfer.com/
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On 2010-11-05 06:30, Tim Diggins wrote:
Is there a way to make this happen? Can I "decorate' those commands somehow to select the relevant lines first... Or would I just have to rewrite those particular features (for each bundle I want them to happen in? )
You can easily "decorate" these commands by creating macros. For each command, create a macro that first selects the line (Edit -> Select -> Line) then does the indentation, comment, or whatever. Selecting a line when you already have a selection converts the entire selection into a line-based selection, which is exactly what you want.
Oh wow. That's perfect. I didn't realize how great and easy macros were.
thanks!
On Tue, Nov 16, 2010 at 2:58 PM, Steve King sking@arbor.net wrote:
On 2010-11-05 06:30, Tim Diggins wrote:
Is there a way to make this happen? Can I "decorate' those commands somehow to select the relevant lines first... Or would I just have to rewrite those particular features (for each bundle I want them to happen in? )
You can easily "decorate" these commands by creating macros. For each command, create a macro that first selects the line (Edit -> Select -> Line) then does the indentation, comment, or whatever. Selecting a line when you already have a selection converts the entire selection into a line-based selection, which is exactly what you want.
-- Steve King Sr. Software Engineer Arbor Networks +1 734 821 1461 www.arbornetworks.com http://www.arbornetworks.com/
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate