vim-topiary


Ⅰ. 插件描述

Trim excess whitespace from Vim buffers on save

Ⅱ. 基本信息

创建日期:  2016-07-31
使用用户:  1
Github星:  5
插件作者:  Scott Stevenson

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'srstevenson/vim-topiary'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'srstevenson/vim-topiary'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'srstevenson/vim-topiary'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/srstevenson/vim-topiary

Ⅳ. 文档说明

# vim-topiary

[vim-topiary] trims excess whitespace from buffers on save. Three types of
whitespace are removed:

  • trailing spaces and tabs at the end of lines
  • blank lines at the start of the buffer
  • blank lines at the end of the buffer

Additionally, multiple consecutive blank lines are collapsed to a single blank
line.

Installation

If you already use a plugin manager such as [vim-plug], [Dein.vim], or [Vundle],
install vim-topiary in the normal manner. Otherwise, the recommended plugin
manager is [minpac]. Add the following to your vimrc ($HOME/.vim/vimrc for Vim
and ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/init.vim for Neovim), restart Vim,
and run :call minpac#update():

call minpac#add('srstevenson/vim-topiary')

If you have Vim 7.4.1840 or newer, you can use the [native package
support][packages] instead of a plugin manager by cloning vim-topiary into a
directory under packpath. For Vim:

git clone https://github.com/srstevenson/vim-topiary \
  ~/.vim/pack/plugins/start/vim-topiary

For Neovim:

git clone https://github.com/srstevenson/vim-topiary \
  ${XDG_DATA_HOME:-$HOME/.local/share}/nvim/site/pack/plugins/start/vim-topiary

Commands

vim-topiary provides the following commands:

  • :TopiaryEnable: Enable whitespace trimming globally.
  • :TopiaryDisable: Disable whitespace trimming globally.
  • :TopiaryToggle: Toggle whitespace trimming globally.
  • :TopiaryEnableBuffer: Enable whitespace trimming for the current buffer.
  • :TopiaryDisableBuffer: Disable whitespace trimming for the current buffer.
  • :TopiaryToggleBuffer: Toggle whitespace trimming for the current buffer.

Key mappings

vim-topiary defines the following <Plug> mappings:

  • <Plug>TopiaryEnable: Execute :TopiaryEnable.
  • <Plug>TopiaryDisable: Execute :TopiaryDisable.
  • <Plug>TopiaryToggle: Execute :TopiaryToggle.
  • <Plug>TopiaryEnableBuffer: Execute :TopiaryEnableBuffer.
  • <Plug>TopiaryDisableBuffer: Execute :TopiaryDisableBuffer.
  • <Plug>TopiaryToggleBuffer: Execute :TopiaryToggleBuffer.

These are not mapped to key sequences, to allow you to choose those that best
fit your workflow and don't conflict with other plugins you use.

Configuration

To disable vim-topiary for specific filetypes, set g:topiary_ft_disabled in
your vimrc file to a list of filetypes. By default vim-topiary is disabled in
diff buffers:

let g:topiary_ft_disabled = ['diff']

You may not want to collapse multiple blank lines in all filetypes. For example
in Python top-level function and class definitions should be surrounded with two
blank lines. In this case only three or more consecutive blank lines should be
collapsed, and to two blank lines rather than one. You can specify this
behaviour for specific filetypes by setting g:topiary_ft_allow_two_blank_lines
in your vimrc to a list of filetypes. By default this is enabled in Python
buffers:

let g:topiary_ft_allow_two_blank_lines = ['python']

Copyright

Copyright © 2016-2019 [Scott Stevenson].

vim-topiary is distributed under the terms of the [ISC licence].

添加新评论