sleuth.vim


Ⅰ. 插件描述

sleuth.vim: Heuristically set buffer options

Ⅱ. 基本信息

创建日期:  2012-12-30
使用用户:  1760
Github星:  982
插件作者:  Tim Pope

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# sleuth.vim

This plugin automatically adjusts 'shiftwidth' and 'expandtab'
heuristically based on the current file, or, in the case the current file is
new, blank, or otherwise insufficient, by looking at other files of the same
type in the current and parent directories. In lieu of adjusting
'softtabstop', 'smarttab' is enabled.

Compare to [DetectIndent][]. I wrote this because I wanted something fully

  1. My goal is that by installing this plugin, you can remove all
  2. related configuration from your vimrc.

Installation

Install using your favorite package manager, or use Vim's built-in package
support:

mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/sleuth.git
vim -u NONE -c "helptags sleuth/doc" -c q

Notes

  • Searching for other files of the same type continues up the directory
    hierarchy until a match is found. This means, for example, the indent for

the first file in a brand new Ruby project might very well be derived from
your .irbrc. I consider this a feature.

  • If your file is consistently indented with hard tabs, 'shiftwidth' will be
    set to your 'tabstop'. Otherwise, a 'tabstop' of 8 is enforced.
  • The algorithm is rolled from scratch, fairly simplistic, and only lightly
    battle tested. It's probably not (yet) as good as [DetectIndent][].

Let me know what it fails on for you.

Self-Promotion

Like sleuth.vim? Follow the repository on
GitHub and vote for it on
vim.org. And if
you're feeling especially charitable, follow tpope on
Twitter and
GitHub.

License

Copyright © Tim Pope. Distributed under the same terms as Vim itself.
See :help license.

添加新评论