sponsor Vim development Vim logo Vim Book Ad

strip_trailing_whitespace.vim : Strip trailing whitespace exactly the way this author wants

 script karma  Rating 12/7, Downloaded by 755  Comments, bugs, improvements  Vim wiki

created by
Tom Ryder
 
script type
utility
 
description
This plugin provides a user command with the author's approach to stripping trailing whitespace from an entire buffer, including removing empty or whitespace-only lines at the end of the buffer, without making command noise and without moving the cursor from its current position.

This is a very commonly written and implemented plugin, but I wrote my own because I could not find a plugin that did this in exactly the way I wanted:

- Accept an optional range
- Strip trailing lines as well as trailing spaces
- Report what was changed, accurately
- Work with even very old Vim (>=6.0)
- Work with a single undo
- Don't move the cursor
- Don't change the search pattern
- Don't define an autocmd
- Don't force a key mapping
- Don't define a global function

https://sanctum.geek.nz/cgit/vim-strip-trailing-whitespace.git
 
install details
Drop plugin/strip_trailing_whitespace.vim in your ~/.vim/plugin directory. Add doc/strip_trailing_whitespace.txt in ~/.vim/doc if you want the help file. Otherwise, use your favourite Vim plugin package manager.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-strip-trailing-whitespace-3.3.0.tar.gz 3.3.0 2024-08-07 6.0 Tom Ryder * Match [:space:] and all Unicode spaces
* Allow -bar after command
* Rename autoloaded interface function
* Simplify cursor restoration
* Add exclamation mark to function declarations
* Inline backported s:Cursor() function
* Move functions into autoload
* Use less worrisome name for a variable
* Remove unneeded variable scoping
* Switch to two-spacing
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github