Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thirtythreeforty/lessspace.vim
Better whitespace stripping for Vim
https://github.com/thirtythreeforty/lessspace.vim
vim whitespace
Last synced: 10 days ago
JSON representation
Better whitespace stripping for Vim
- Host: GitHub
- URL: https://github.com/thirtythreeforty/lessspace.vim
- Owner: thirtythreeforty
- Created: 2015-05-30T17:32:03.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-02-13T21:20:34.000Z (over 1 year ago)
- Last Synced: 2024-10-13T20:43:45.002Z (25 days ago)
- Topics: vim, whitespace
- Language: Vim Script
- Size: 29.3 KB
- Stars: 70
- Watchers: 5
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LessSpace.vim
This simple plugin will strip the trailing whitespace from the file you are editing.
However, it does this only on the lines you edit or visit in Insert mode; it leaves all the others untouched.I wrote this plugin because I work with people whose editors don't clean up whitespace.
My editor (Vim) *did* strip all whitespace, and saving my edits caused a lot of extraneous whitespace changes that showed up in version control logs.
This plugin gives the best of both worlds: it cleans up whitespace on edited lines only, keeping version control diffs clean.## Installation
If you don't have a preferred installation method, I recommend installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and then simply copy and paste:
cd ~/.vim/bundle
git clone git://github.com/thirtythreeforty/lessspace.vim## Usage
For basic usage, just install it and forget it.
LessSpace works automatically.LessSpace provides a couple commands that allow you to turn it on or off, either globally or per-buffer.
The global commands are:- `LessSpace`: Turn on whitespace stripping
- `LessSpace!`: Turn off whitespace strippingThe per-buffer commands are very similar:
- `LessSpaceBuf`: Turn on whitespace stripping
- `LessSpaceBuf!`: Turn off whitespace stripping## Configuration
LessSpace doesn't offer many configuration options, because everything happens automatically when you enter and leave Insert mode.
You can disable LessSpace on startup by setting the `g:lessspace_enabled` variable:
let g:lessspace_enabled = 0
(The same effect can be achieved after startup by just running `:LessSpace!`.)
By default, LessSpace strips whitespace after normal mode operations (such as when you paste something from a register).
If you don't want this, you can have LessSpace only work in insert mode by setting `g:lessspace_normal`:let g:lessspace_normal = 0
You can also specify the filetypes that it operates on by specifying a filetype whitelist or blacklist.
(Perhaps, for example, you're writing [Whitespace](https://en.wikipedia.org/wiki/Whitespace_%28programming_language%29).)
You can change this by setting either of the `g:lessspace_whitelist` or `g:lessspace_blacklist` variables, preferably in your `vimrc` file.
These variables should be lists of the desired filetypes.
For example, to only operate on Vim and Ruby files, you could use:let g:lessspace_whitelist = ['ruby', 'vim']
And to operate on everything but `diff` files (this is the default):
let g:lessspace_blacklist = ['diff']
(Previously, the whitelist had to be specified as a regex string.
This has been deprecated and removed; you should update to the list-based method.)## Integrating
If LessSpace bothers your plugin, you can call these functions to temporarily disable it while your plugin runs:call lessspace#TemporaryDisableBegin()
call lessspace#TemporaryDisableEnd()In such cases, please file an issue on GitHub to see if we can make the integration better!
## License
Copyright © 2015-2018 George Hilliard. Distributed under the same terms as Vim itself.
See `:help license`.