Ⅰ. 插件描述
Strip trailing whitespace only on changed linesⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'tweekmonster/wstrip-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'tweekmonster/wstrip-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'tweekmonster/wstrip-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/tweekmonster/wstrip.vim
Ⅳ. 文档说明
# wstrip.vim
Strip trailing whitespace only on changed lines. Inspired by question on
StackExchange's Vi and Vim website.
Summary
This plugin uses git-diff to strip whitespace from lines that you changed
while editing. This allows you to keep newly added lines clean without
affecting the history of existing lines.
If the file is not in a git repository, diff is used to make a simple
comparison against the existing file on disk.
Usage
Whitespace can be automatically stripped when writing the buffer by settingg:wstrip_auto or b:wstrip_auto to 1. This is disabled by default.
" Globally enabled for all filetypes
let g:wstrip_auto = 1
" Just certain filetypes
autocmd FileType *.css,*.py let b:wstrip_auto = 1 If you don't want automatic cleaning, the :WStrip command can be used to
manually clean whitespace.
Trailing whitespace will be highlighted using the WStripTrailing syntax
- If it appears that Vim is capable of underlining text, trailing
- will be highlighted as a red underline. Otherwise, it will
highlighted with a red background. To disable highlighting, setb:wstrip_highlight or g:wstrip_highlight to 0.
If you want to allow a certain amount of trailing whitespace, you can setb:wstrip_trailing_max to the maximum number of whitespace characters that are
allowed to be at the end of a line. By default, this is set to 2 for themarkdown filetype.
License
MIT