Don't trim whitespace when indenting/unindenting

Ideas for new features

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply

Useful?

Yes
1
33%
No
2
67%
 
Total votes: 3

jumpfroggy
Posts: 23
Joined: Fri Jan 14, 2005 9:28 pm

Don't trim whitespace when indenting/unindenting

Post by jumpfroggy »

When you select a region and indent or unindent, you lose any lines with only whitespace (they're trimmed down to just empty lines). This means that if you had your code formatted as such:

Code: Select all

function one() {
...do something
...
...do something else
}

Indent it, turns into:

...function one() {
......do something

......do something else
...}
That middle line is now blank. When you go to type more code in between you have to add the whitespace back in. It'd be better to keep the whitespace intact. The "Strip Trailing Spaces on save" setting is available for those who want blank lines, but if I have it off (as I do) I want to be able to preserve those whitespaces on indent.
markeb
Posts: 2
Joined: Sun Dec 04, 2005 10:39 pm
Contact:

This is annoying

Post by markeb »

I agree... This is *EXTREMELY* annoying. If anyone has any way to overwrite the default Increase/Decrease Indent functionality, PLEASE post a solution.

This could actually cause me to stop using TextPad altogether.
~Mark
--------------------------------------------------
Cyberspeed Solutions
www.cyberspeedsolutions.com
--------------------------------------------------
jumpfroggy
Posts: 23
Joined: Fri Jan 14, 2005 9:28 pm

Post by jumpfroggy »

markeb, say it aint so! Don't give up!

Quite honestly, it seems like Helios is done with Textpad. Not that they wont offer any more updates, but that they're done adding more features. They've come so close to perfection with what they have, but they haven't fixed any of the subtle bugs like these.

Thinking creatively, would there be any way to externally script commands like these? Other threads have talked about a general purpose external piping tool, where you could select text and push a button to pipe that text into a tool and replace it with the output. Can we do the same kind of thing with this tab problem?

The actual indenting could be handled as described with a "pipe-hack". But the indent in textpad actually auto-selects whole lines, so if you've got half of one line and half of another selected, it'll first select both whole lines before it indents. How could we simulate this with an external tool? (I'm thinking capturing keystrokes, monitoring windows messages, etc). Any thoughts?

markeb: as a workaround, you could periodically run a regex script that would automatically replace those missing tabs... let me see if I remember.

find: ^(\t*)(.+)\n^\n
replace: \1\2\n\1\n

That will replace all blank lines with however many tabs the preceding line has. Try it out. If you use spaces, replace "\t" with however many spaces you have set (4 is default, I think). Let me know if that helps, as a hack/workaround.

Helios, come-on!
Post Reply