wordcount.vim


Ⅰ. 插件描述

A quick word count plugin for Vim, perfect for adding to your statusline

Ⅱ. 基本信息

创建日期:  2015-01-02
使用用户:  2
Github星:  7
插件作者:  Chesley Tan

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

wordCount.vim

A quick word count plugin for Vim, perfect for adding to your statusline

Manual Installation

Clone this repository to $HOME/.vim/bundle

$ mkdir -p $HOME/.vim/bundle
$ git clone https://github.com/ChesleyTan/wordCount.vim $HOME/.vim/bundle/wordCount.vim

Add the following to your .vimrc

set runtimepath+=$HOME/.vim/bundle/wordCount.vim

Usage

This plugin provides the function wordCount#WordCount() which returns a count of the number of words in the buffer (or in the directly preceding visual selection), as well as the command WordCount which prints out the word count.

Visual Mode

For a word count of a visual selection, you must make your selection, escape visual mode, and call the word count function or command before moving your cursor in normal mode. Because Vim does not have an autocmd event for Visual enter/exit, this plugin can only be informed of the current mode when the cursor moves. Therefore, a word count of a visual selection can only be done if the cursor is moved while in visual mode.

Conservative updating (enabled by default)

The conservative updating option g:wc_conservative_update forces the plugin to only update the word count when one of the following events occurs:

  • Vim leaves insert mode
  • A change is made in normal mode
  • A new buffer is opened

This is useful if you plan to add the word count to your statusline.

Adding a word count to your statusline

This can be done simply with set statusline+=%{wordCount#WordCount()}

添加新评论