I know there's a method of deleting trailing spaces, extraneous blank lines, and for turning tabs into spaces... But I can't seem to find anything that will delete leading spaces from a document. Anyone have any ideas? I've read the help docs, scoured the forums, tried pressing random key combinations while doing a one-armed hand-stand and re-reading the help files (okay, it wasn't a ONE-ARMED hand-stand but come on give me a break, I was reading the help files upside on my monitor waaaay up on my desk)... *g*
Seriously though, I've looked all over (even Google'd it) and I'm stuck... I've got a large (somewhere around 27,000 lines long) text document and there's situations like this:
-- example of my text, somewhat exaggerated to show the spacing problem clearly --
Text on one line has none.
This line has three leading spaces.
But this one might only have one.
This line, leading a new "block" of related text lines off, may start with one.
And the other two lines may have none.
Zip, zero, nada. Just sort of random like this.
-- end of my example --
I want to preserve the blank lines between "blocks" of data (there's four lines to each "block") because the data in the first line essentially is a title and the following lines all relate to it - and all of the few thousand "blocks" follow this same exact structure. Aside from the seemingly random leading spaces (which is all I need to be rid of to be able to actually USE this huge chunk of data) the file is nearly perfect for what I need Notepad++ to be able to do to it.
Thanks for any help you can provide me, and thanks for taking the time to read this if you can't help me.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I keep thinking for these one-pass things, it actually is faster to use the replace function. No need to open the Script Writer, write the script and execute it, and close the thing again.
Either CTRL+F or CTRL+R allows you to use regular expressions to replace "a number" of spaces "anywhere". Use ^ to indicate the match has to be at the beginning of the line.
In the Find field, enter:
^ +
or, to include tab characters in the match pattern:
^[ \t]+
Make sure the Replace field is (left) blank.
Check regular expressions.
Uncheck Selection.
Move the cursor to the top of the document.
Replace all occurrences.
[ \t] means that either a space or tab character has to be matched.
+ means that any number of consecutive matched characters will be included in the match.
So any string of (combination of) space and tab characters from the beginning of the line will be included.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
>You've read the help docs, scoured the forums, tried pressing random key combinations while doing a >one-armed hand-stand and re-reading the help files.
...but you don´t see in Edit menu the "Trim Trailing Space" option?
And for me it works fine.
Best Regards.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To the anonymous poster - I was NOT looking to delete trailing spaces, I was looking to delete LEADING spaces.
fidvo - thanks, that worked wonderful... and I found a regular expression comment on another post somewhere that would likely do the trick too. I appreciate your help. ^_^ Saved me from having to dread wasting a ton of time to do that by hand! :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I know there's a method of deleting trailing spaces, extraneous blank lines, and for turning tabs into spaces... But I can't seem to find anything that will delete leading spaces from a document. Anyone have any ideas? I've read the help docs, scoured the forums, tried pressing random key combinations while doing a one-armed hand-stand and re-reading the help files (okay, it wasn't a ONE-ARMED hand-stand but come on give me a break, I was reading the help files upside on my monitor waaaay up on my desk)... *g*
Seriously though, I've looked all over (even Google'd it) and I'm stuck... I've got a large (somewhere around 27,000 lines long) text document and there's situations like this:
-- example of my text, somewhat exaggerated to show the spacing problem clearly --
Text on one line has none.
This line has three leading spaces.
But this one might only have one.
This line, leading a new "block" of related text lines off, may start with one.
And the other two lines may have none.
Zip, zero, nada. Just sort of random like this.
-- end of my example --
I want to preserve the blank lines between "blocks" of data (there's four lines to each "block") because the data in the first line essentially is a title and the following lines all relate to it - and all of the few thousand "blocks" follow this same exact structure. Aside from the seemingly random leading spaces (which is all I need to be rid of to be able to actually USE this huge chunk of data) the file is nearly perfect for what I need Notepad++ to be able to do to it.
Thanks for any help you can provide me, and thanks for taking the time to read this if you can't help me.
I'm sure you can do it with regular expressions, but I prefer to use the Simple Script plugin (admittedly that's mostly because I created it).
The script is a one-liner:
TrimLeft(" \t")
Make sure there's a space before the backslash. "\t" means TAB, so this would trim all leading spaces and tabs from the left end of each line.
You'll need to download Simple Script separately if you haven't already.
There's also a TrimRight and a Trim function.
I keep thinking for these one-pass things, it actually is faster to use the replace function. No need to open the Script Writer, write the script and execute it, and close the thing again.
Either CTRL+F or CTRL+R allows you to use regular expressions to replace "a number" of spaces "anywhere". Use ^ to indicate the match has to be at the beginning of the line.
In the Find field, enter:
^ +
or, to include tab characters in the match pattern:
^[ \t]+
Make sure the Replace field is (left) blank.
Check regular expressions.
Uncheck Selection.
Move the cursor to the top of the document.
Replace all occurrences.
[ \t] means that either a space or tab character has to be matched.
+ means that any number of consecutive matched characters will be included in the match.
So any string of (combination of) space and tab characters from the beginning of the line will be included.
>You've read the help docs, scoured the forums, tried pressing random key combinations while doing a >one-armed hand-stand and re-reading the help files.
...but you don´t see in Edit menu the "Trim Trailing Space" option?
And for me it works fine.
Best Regards.
To the anonymous poster - I was NOT looking to delete trailing spaces, I was looking to delete LEADING spaces.
fidvo - thanks, that worked wonderful... and I found a regular expression comment on another post somewhere that would likely do the trick too. I appreciate your help. ^_^ Saved me from having to dread wasting a ton of time to do that by hand! :)