Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/csexton/trailertrash.vim
Identify and Irradicate unwanted whitespace at the end of the line
https://github.com/csexton/trailertrash.vim
Last synced: 3 months ago
JSON representation
Identify and Irradicate unwanted whitespace at the end of the line
- Host: GitHub
- URL: https://github.com/csexton/trailertrash.vim
- Owner: csexton
- License: other
- Created: 2011-03-21T20:06:52.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2023-09-22T21:10:54.000Z (about 1 year ago)
- Last Synced: 2024-05-31T12:35:01.541Z (6 months ago)
- Language: Vim Script
- Homepage:
- Size: 27.3 KB
- Stars: 57
- Watchers: 3
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Trailer Trash for Vim
Eradicate unwanted whitespace at the end of the line in Vim.
This plugin will highlight trailing whitespace at the end of the line. This is done in a polite way:
* You are not currently editing that line (prevents highlighting it as you type)
* You are not in insert modeIt also introduces a `:TrailerTrim` command that will strip all the trailing white space from a file (or range). This is done in a polite way:
* Places the cursor back where is started
* Resets the search highlight back to what it wasTrailerTrash defines a `:TrailerToggle` command to stop showing unwanted whitespace, for those projects where you don't want to start fighting it.
As always, Trailer Trash is polite.
### Install using vim-plug
```
Plug 'csexton/trailertrash.vim'
```### Ignoring Specific file types
You can ignore specific file types by adding an exclude list to your `.vimrc` file. If you have any specific types that should always be ignored please send a pull request or open an issue.
let g:trailertrash_blacklist = ['__Calendar', '^http:']
### Styling TrailerTrash
You can modify the appearance of TrailerTrash with the `hi UnwantedTrailerTrash` setting.
For example, you can set the background of all trailing trash to red with the following:
hi UnwantedTrailerTrash guibg=red ctermbg=red
### Disabling TrailerTrash
In most cases, if you want to hide the highlighting you can simply call `:TrailerHide`, and toggle it back on at any time.
If you want something more extreme, and want stop the underlying mechnism from working all together you can clear the `2match` in vim:
TrailerTrash uses `2match` ([vimdoc](http://vimdoc.sourceforge.net/htmldoc/pattern.html#match-highlight)) to define a highlight pattern. If you would like to disable it you can call `2match none`. This works great in plugins that provide you a hook to customize buffers, such as Unite's `unite_settings()`
```viml
function! s:unite_settings()
2match none
endfunction
```----
This is [not](http://blog.kamil.dworakowski.name/2009/09/unobtrusive-highlighting-of-trailing.html) [an](http://vim.wikia.com/wiki/Remove_unwanted_spaces) [original](http://vimcasts.org/episodes/tidying-whitespace/) [idea](http://vim.wikia.com/wiki/Highlight_unwanted_spaces), I just gathered tips and ideas from around the web and bundled them together in a way I liked.
# License
Copyright (c) Christopher Sexton. Distributed under the same terms as Vim itself. See `:help license`.