I just tried, using Joe 3,5: "\* \$" is wrong. It removes everthing from the actual cursor position (or the beginning of another line) to the end of the line if the line ends with a space.
The correct search string must be "\+ \$". Spaces within the line are not affected, because "\$" matches the end of the line.
Btw, to remove trailing tabs as well, "\+\[ <Ctrl>I\]\$" is needed, where you enter the "<Ctrl>I" by hitting <Ctrl>q followed by <Ctrl>i.
I agree that perl-compatible regular expressions (PCRE) would be nice. I have used the PCRE package for some other project but have not yet looked into how much work it would be to use it with Joe.
Would there be any interest in getting it done, I mean, more than two votes (blhsing's and mine)?
Are there any counterarguments?
As for automatically removing trailing whitespace - I would vote against it, because there may be cases where trailing whitespace it needed, e.g. when you want to have "\ " at the enf of line in a C-file. The trailing space prevents the "\" to be interpreted as continuation character. As an option that could be selected or not, maybe depending on the file type, like wordwrap, it would be fine by me.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You're more likely to get all the trailing spaces in one go if you start at the end of the file and work backwards... (jstar keystrokes shown here)
^Qc
^Qa
Find: <space>\n (space, then EOL)
(options): rb
Replace with: \n (just EOL)
Replace .. : r (rest)
Joe/jstar, like WordStar before it, appears to resume at the change-point when working globally backwards, so it iteratively catches all the trailing spaces, so you don't have to specify or glob their count.
---
PCRE would be nice, but it's not that hard to mark a block and then shell it through a Perl oneliner or existing script (jstar: ^Kb, ^Kk, ^K/).
cr
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is an old thread but it's exactly what I came here to look up.
In my DOS days I used an editor called QEdit that had such a feature. As I recall it was an option in the configuration that once turned on caused all trailing spaces on lines to be dropped when the file was saved. It would be nice to have an option like this in joerc.
I've been using joe for 8-9 years under OpenBSD and I like it a lot.
Alan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello!
is there a way to clear the spaces at the end of all lines in a file? This would be great.
From the beginning of the file, search for (two spaces in the following pattern):
\* \$
and replace with nothing.
Would be nice if standard (or even better, Perl-like) regular expression is supported, though.:-)
Thank you!
this is great but doesnt it also remove spaces from inside strings?
how about having joe automatically strip blanks at the end of a line on save or when the cursrom moves off the line containing them?
I just tried, using Joe 3,5: "\* \$" is wrong. It removes everthing from the actual cursor position (or the beginning of another line) to the end of the line if the line ends with a space.
The correct search string must be "\+ \$". Spaces within the line are not affected, because "\$" matches the end of the line.
Btw, to remove trailing tabs as well, "\+\[ <Ctrl>I\]\$" is needed, where you enter the "<Ctrl>I" by hitting <Ctrl>q followed by <Ctrl>i.
I agree that perl-compatible regular expressions (PCRE) would be nice. I have used the PCRE package for some other project but have not yet looked into how much work it would be to use it with Joe.
Would there be any interest in getting it done, I mean, more than two votes (blhsing's and mine)?
Are there any counterarguments?
As for automatically removing trailing whitespace - I would vote against it, because there may be cases where trailing whitespace it needed, e.g. when you want to have "\ " at the enf of line in a C-file. The trailing space prevents the "\" to be interpreted as continuation character. As an option that could be selected or not, maybe depending on the file type, like wordwrap, it would be fine by me.
You're more likely to get all the trailing spaces in one go if you start at the end of the file and work backwards... (jstar keystrokes shown here)
^Qc
^Qa
Find: <space>\n (space, then EOL)
(options): rb
Replace with: \n (just EOL)
Replace .. : r (rest)
Joe/jstar, like WordStar before it, appears to resume at the change-point when working globally backwards, so it iteratively catches all the trailing spaces, so you don't have to specify or glob their count.
---
PCRE would be nice, but it's not that hard to mark a block and then shell it through a Perl oneliner or existing script (jstar: ^Kb, ^Kk, ^K/).
cr
This is an old thread but it's exactly what I came here to look up.
In my DOS days I used an editor called QEdit that had such a feature. As I recall it was an option in the configuration that once turned on caused all trailing spaces on lines to be dropped when the file was saved. It would be nice to have an option like this in joerc.
I've been using joe for 8-9 years under OpenBSD and I like it a lot.
Alan