Smart Parentheses


Ⅰ. 插件描述

Minimal but smart parentheses handling for programming

Ⅱ. 基本信息

创建日期:  2010-08-18
使用用户:  10
Github星:  1
插件作者:  Niels Aan de Brugh

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

Actually most types of brackets are supported, as long it works with %. This script aims to provide some useful tricks of ParEdit but be less restrictive and more geared towards C-style programming rather than Lisp. It has less than 5% of ParEdit probably, if you want something more similar, look for slimev.

This makes the open brackets (, [, and < introduce a balanced pair. If there is already an unbalance, the script determines if adding a closing bracket makes matters better or worse. In the latter case, the closing bracket is not added.

Typing the close bracket checks if the next non-whitespace character is already that same symbol. If it is, the script just zaps all white-space until the existing symbol and moves past it. If there is no closing symbol, a new closing bracket is introduced. (Note that is much less restrictive than ParEdit but also much less safe).

For { a special case exists: typing a second { in a row introduces extra newlines for C-style programming rather than a nested pair of curly brackets. Also, } doesn't remove all white-space like the other brackets do. Again, this is convenient for programming.

In normal mode, you can type a number N and then an opening bracket, and the script will put brackets around the following N words, similar to what you can do in ParEdit.

添加新评论