indent-motion


Ⅰ. 插件描述

Vim motions to the start and end of the current indentation-delimited block

Ⅱ. 基本信息

创建日期:  2011-08-12
使用用户:  42
Github星:  5
插件作者:  Taylor Hedberg

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

indent-motion

indent-motion is a Vim plugin which maps <Leader>[ and <Leader>] in normal, visual, and operator-pending modes to move to the beginning and end (respectively) of your current indentation-delimited block (<Leader> refers to your current user-defined "mapleader", which is \ by default).

For example (using JavaScript):

function foo(a, b, c) {
    var x = 1;
    var y = 2;
    if (x == y) {
        alert("This will never happen!");
        ++y;
    }
}

In the above snippet, if the cursor is positioned on the var x = 1; line, then <Leader>] will move the cursor to the next-to-last line (closing brace of the conditional block) and <Leader>[ will move it back to the original location. If the cursor is positioned on the alert call, then <Leader>] will move down 1 line to ++y;.

If one of the mappings is executed on an empty line (containing no characters, not even whitespace), then the assumed indentation will be that of the next non-empty line, where "next" is in the direction of the requested motion.

Currently, the mappings are not configurable, but this can easily be changed upon request.

添加新评论