vim-indenty


Ⅰ. 插件描述

Vim plugin that detects what indent options were used in the file and sets them.

Ⅱ. 基本信息

创建日期:  2016-07-18
使用用户:  1
Github星:  7
插件作者:  Mariusz Glebocki

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

Indenty

Vim plugin that detects what indent options were used in the file and sets them.

Description

Indenty detects indent type (tabs/spaces, expandtab), and indent size (shiftwidth/[soft]tabstop) for spaces. The latter is sometimes detected for tabs, but requires a columns indented inside the text with varying number of tabs, e.g.:

/* good look with ts=4 */
struct example {
⇥   int⇥⇥   tabstop;
⇥   int⇥⇥   softtabstop;
⇥   int⇥⇥   shiftwidth
⇥   bool⇥   tabstop
};

/* messed up with ts=8 */
struct example {
⇥       int⇥    ⇥       tabstop;
⇥       int⇥    ⇥       softtabstop;
⇥       int⇥    ⇥       shiftwidth;
⇥       bool⇥   expandtab;
};

Tabstop detection for tabs uses configurable priorities. The default priorities are [4, 8, 2], so 4 was chosen in the example, despite the fact that it also looks good with tabstop set to 2.

Only the current file is scanned. By default, the plugin respects modelines in a 5 first/last lines and stops detection when it is found. Nothing is changed also when the detection fails to find something reasonable.

Requirements

Vim with Python 3. Python 2 might work, it is not tested yet.

Settings

OptionTypeDescription
g:indenty_tabstop_prioritylistSpecifies what tabstop widths to check when the tab indentation is detected. The first good looking width is used.
g:indenty_modelinesnumberThe number of lines that are checked for a modeline presence.
g:indenty_blacklistlistFiletypes for which automatic detection is not triggered. IndentyDetect() still works.
g:indenty_min_linesnumberThe minimum number of indented lines required to set detected settings.
g:indenty_max_linesnumberThe maximum number of lines that are scanned.
g:indenty_onloadbooleanWhen on, the file is scanned automatically when it is opened.
g:indenty_show_msgbooleanSpecifies whether to show message with detected settings.
g:indenty_msg_hlstringThe message highlight group.
g:indenty_detailed_msgbooleanWhen on, instead of simple description - all vim settings related to indents are shown.

Defaults:

g:indenty_tabstop_priority  = [4, 8, 2]
g:indenty_modelines         = &modelines
g:indenty_blacklist         = ['help', 'man', '', 'make']
g:indenty_min_lines         = 4
g:indenty_max_lines         = 1024
g:indenty_onload            = 1
g:indenty_show_msg          = 1
g:indenty_msg_hl            = 'WarningMsg'
g:indenty_detailed_msg      = 0

Commands

FunctionDescription
IndentyDetect()Triggers detection.

添加新评论