hi
I hate whitespace at the end of lines or files, so I wondered if there's a way to automatically remove those. I could probably define a command to do this, but I still would have to start it manually.
IMO it would be nice if TextMate allowed running commands on certain events, especially on saving the current document. This would not only solve my problem, but would also allow other maybe useful automatisms like automatically re-building a project on saving or something like that.
What do you think about this idea?
On 23-04-2005 22:53, Frank Schönmann wrote:
IMO it would be nice if TextMate allowed running commands on certain events, especially on saving the current document. This would not only solve my problem, but would also allow other maybe useful automatisms like automatically re-building a project on saving or something like that.
What do you think about this idea?
This was mentioned a couple of days back in IRC, but there's always the possibility for you to make a macro of this. Record macro, do whatever you want to do, save file, end macro and save macro to whatever key you want.
Jeroen.
On 24-04-2005, at 02:01, Jeroen van der Ham wrote:
On 23-04-2005 22:53, Frank Schönmann wrote:
IMO it would be nice if TextMate allowed running commands on certain events, especially on saving the current document. This would not only solve my problem, but would also allow other maybe useful automatisms like automatically re-building a project on saving or something like that. What do you think about this idea?
This was mentioned a couple of days back in IRC, but there's always the possibility for you to make a macro of this. Record macro, do whatever you want to do, save file, end macro and save macro to whatever key you want.
But hooks for things like save, load etc. would be pretty useful for things like that. But yeah it's been discussed on IRC... I don't remember what the outcome was, but maybe 'will come later'?
+1 for hooks on events.
I posted recently about my modifications to the macro in Text Utilities. There's a 'Strip trailing spaces' command that is based upon the selection. I modified a copy of one to do the whole document and gave it a hot key. It's not perfect (I hate that it leaves the whole document selected), but it's a work around for the moment.
On Apr 24, 2005, at 6:57 AM, Sune Foldager wrote:
On 24-04-2005, at 02:01, Jeroen van der Ham wrote:
On 23-04-2005 22:53, Frank Schönmann wrote:
IMO it would be nice if TextMate allowed running commands on certain events, especially on saving the current document. This would not only solve my problem, but would also allow other maybe useful automatisms like automatically re-building a project on saving or something like that. What do you think about this idea?
This was mentioned a couple of days back in IRC, but there's always the possibility for you to make a macro of this. Record macro, do whatever you want to do, save file, end macro and save macro to whatever key you want.
But hooks for things like save, load etc. would be pretty useful for things like that. But yeah it's been discussed on IRC... I don't remember what the outcome was, but maybe 'will come later'?
-- Sune.
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On Apr 24, 2005, at 18:02, Robert M.Zigweid wrote:
+1 for hooks on events.
Yes, this is something which will appear, but it's not really around the corner.
I may add a special setting for stripping trailing spaces until then or modify the behavior of return so it doesn't leave the spaces when pressing return on a line with only spaces, although I do think this would clash slightly with some of my own editing patterns.
On Apr 25, 2005, at 7:45 AM, Allan Odgaard wrote:
On Apr 24, 2005, at 18:02, Robert M.Zigweid wrote:
+1 for hooks on events.
Yes, this is something which will appear, but it's not really around the corner.
I may add a special setting for stripping trailing spaces until then or modify the behavior of return so it doesn't leave the spaces when pressing return on a line with only spaces, although I do think this would clash slightly with some of my own editing patterns.
It conflicts with mine as well; removing 'extra' spacing automatically would be a major pain for me.
-1
Best, Eric
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On Apr 26, 2005, at 12:40 AM, Eric Ocean wrote:
It conflicts with mine as well; removing 'extra' spacing automatically would be a major pain for me.
just out of curiosity: would you mind explaining? i simply cannot imagine a programming style where trailing whitespace would be of any significance... both you and allan have piqed my interest here ;-)
best regards,
tom
Tom Lazar http://tomster.org
On 26-04-2005, at 05:30, Tom Lazar wrote:
On Apr 26, 2005, at 12:40 AM, Eric Ocean wrote:
It conflicts with mine as well; removing 'extra' spacing automatically would be a major pain for me.
just out of curiosity: would you mind explaining? i simply cannot imagine a programming style where trailing whitespace would be of any significance... both you and allan have piqed my interest here ;-)
I recall a programming language called white-space where trailing white-space would matter quite a lot. But I am not sure how widely used that language is in the industry ;-).
Otherwise I agree with Tom; When do you NOT want to strip it on save?
On Apr 26, 2005, at 9:51, Sune Foldager wrote:
Otherwise I agree with Tom; When do you NOT want to strip it on save?
When your source is under source control and other work on the source as well. Stripping ws on save may cause a lot of lines to be changed, and thus the likelihood of merge conflicts and screwed up history is big.
However, I was talking about editing patterns about having return remove ws to the left.
If I have code like:
|one_expression; // caret in the start of this line other_expression;
I may want to add a trace statement above “one_expression”, I do that using, return, arrow-up, log<tab> (snippet doing the trace expression).
If return hadn't preserved the ws then I'd need to do a few tabs first. I may however make tab indent to current level, when line has less ws than current level and is otherwise empty.
Ideally I should keep “virtual” ws around for these situations and remove that on save. So it's there if the user expects it, but it's not persistent.
On Apr 26, 2005, at 9:56, Allan Odgaard wrote:
However, I was talking about editing patterns about having return remove ws to the left. [...]
Here's another that I also use a lot:
if(some_condition) | expression; // caret is denoted by |
If I want to bracket the expression I do: return cmd-return delete (backwards) 2 x shift arrow up {
And I have: if(some_condition) { expression; }|
Maybe I should make a macro, but I do this almost w/o thinking, and it comes in many flavors (to bracket stuff), so one macro probably wouldn't be sufficient -- so all in all, having return remove whitespace is not cool with me. But the virtual indent I mentioned would be :)
I'm not entirely certain that I would want it to be done automatically either.
My current work around is really quite satisfactory, with the exception that the command leaves the entire document highlighted. THAT is annoying. I can't just clean the trailing white space and keep typing. Maybe I'm missing something here.
I would probably be okay for a toggle option to strip on save too. Whatever solution, I think it should be an option. JMHO
On Apr 26, 2005, at 5:51 AM, Allan Odgaard wrote:
On Apr 26, 2005, at 9:56, Allan Odgaard wrote:
However, I was talking about editing patterns about having return remove ws to the left. [...]
Here's another that I also use a lot:
if(some_condition) | expression; // caret is denoted by |
If I want to bracket the expression I do: return cmd-return delete (backwards) 2 x shift arrow up {
And I have: if(some_condition) { expression; }|
Maybe I should make a macro, but I do this almost w/o thinking, and it comes in many flavors (to bracket stuff), so one macro probably wouldn't be sufficient -- so all in all, having return remove whitespace is not cool with me. But the virtual indent I mentioned would be :)
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On Apr 26, 2005, at 12:17, Robert M.Zigweid wrote:
My current work around is really quite satisfactory, with the exception that the command leaves the entire document highlighted. THAT is annoying.
Okay, for now do: cmd-option-M (start macro recording) option-shift-R (filter through command) set in/out to document and command: perl -pe 's/[\t ]+$//g' arrow left (deselects text) cmd-option-M (stop macro recording)
Now save the macro (ctrl-cmd-M) and give it a name + key equivalent.
Probably though I should not let the 'replace document' output option leave the document selected.