- Subject: Re: [jed-users] rm trailing whitespace on write
- From: Guenter Milde <milde@xxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 16 Feb 2017 11:51:45 +0100
On 16.02.17, Bernhard Seckinger wrote:
> Hi pdg,
> > Anybody have a mechanism to remove trailing whitespace
> > on buffer write (or read I guess).
> I'm not sure, if this is, what you're looking for, but I use the following in
> my .jedrc to remove trailing whitespaces, whenever I save the buffer:
> define my_trim_buffer()
> {
> push_spot();
> while (up_1()) { eol_trim(); bol(); }
> pop_spot();
> push_spot();
> while (down_1()) { eol_trim(); bol(); }
> pop_spot();
> }
> add_to_hook("_jed_save_buffer_before_hooks",&my_trim_buffer);
> Note, that it does not remove empty lines at the end of the buffer.
Here is another variant, that also removes trailing multiple empty lines
(but leaves the newline char on the last line intact):
% Trim buffer but keep multiple blank lines:
public define trim_buffer_lines()
{
% remove whitespace at end of lines
push_spot_bob();
do {
eol_trim();
}
while (down_1());
% remove empty lines at end of buffer
eob();
do {
go_left_1();
if (bolp() and eolp())
del();
}
while (bolp());
pop_spot();
!if (BATCH) message ("done.");
}
_______________________________________________
For list information, visit <http://jedsoft.org/jed/mailinglists.html>.
[2017 date index]
[2017 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]