la 9. marrask. 2024 klo 13.56 Benno Schulenberg (bensb...@telfort.nl) kirjoitti: > Op 09-11-2024 om 11:17 schreef Martin-Éric Racine: > > I have 'set trimblanks' in .nanorc and yet, most of the time, files get > > saved > > with some trailing whitespace remaining. > > One could argue that the option is poorly named, but... users should > really read the documentation. For trimblanks, `man nanorc` says: > "Snip trailing whitespace from the wrapped line _when_ automatic > hard-wrapping occurs or _when_ text is justified."
Poorly named is an understatement, since this actually is conditional to actions within the editor. > > Setting the option really should trim at all times, prior to saving a file. > > You can arrange the trimming of all trailing whitespace yourself. > Search for "snipping" in the sample nanorc: > > grep -A1 snipping /usr/share/doc/nano/examples/sample.nanorc > > That gives: > > ## For snipping trailing blanks when you save a file: > # bind ^S "{execute}| sed 's/\s\+$//' {enter}{savefile}" main Which really isn't quite the same. This now requires using an entirely different keystroke than the usual save action. Martin-Éric