vim-textobj


Ⅰ. 插件描述

Allows configuration of custom text objects

Ⅱ. 基本信息

创建日期:  2007-09-09
使用用户:  1
Github星:  3
插件作者:  Jesse Luehrs

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# Overview

This plugin allows configuration of custom text objects, to perform actions on
additional sections of text than Vim has built-in.

Installation

This plugin can be installed as a standard Vim package (see :help packages).
Simply clone this repository into ~/.vim/pack/plugins/start/vim-textobj to
install the Vim files for this plugin.

Configuration

Configuration is done by setting the g:textobj_defs variable to a dict which
maps input keys to a list containing the text object type and arguments to pass
to that type. For instance:

    let g:textobj_defs = {
    \    '/': ['paired'],
    \    'r': ['paired', '/'],
    \    '\|': ['paired'],
    \    'f': ['fold'],
    \    ',': ['arg'],
    \}

This defines five text object characters: / and r (for regex?) for text
within matching pairs of / characters, | for text within matching pairs of
| characters, f for text within the current fold, and , for the current
argument in a comma-separated function argument list. This, for instance,
allows you to use di/ to delete the text within a Perl regex.

Currently, these are the available types:

  • paired: matches text between pairs of characters. Takes one optional
    argument for the character to match between, which defaults to the input

character.

  • fold: matches the text within the current fold. Takes no arguments.
  • arg: matches the current function argument. Given text like
    foo(bar, b|az, quux) (where | is the cursor location), if , is the

input character, da, will result in foo(bar, |quux) and di, will
result in foo(bar, |, quux) . Takes no arguments.

添加新评论