sponsor Vim development Vim logo Vim Book Ad

sleuth.vim : Heuristically set buffer options

 script karma  Rating 407/143, Downloaded by 3801  Comments, bugs, improvements  Vim wiki

created by
Tim Pope
 
script type
utility
 
description
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 (vimscript #1171).  I wrote this because I wanted something fully automatic.  My goal is that by installing this plugin, you can remove all indenting related configuration from your vimrc.

https://github.com/tpope/vim-sleuth
 
install details
Extract in ~/.vim (~\vimfiles on Windows).
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
sleuth.zip 2.0 2022-04-29 7.0 Tim Pope Set endofline, fileformat, fileencoding, bomb from EditorConfig.
Set filetype from modeline and EditorConfig.
Set softtabstop to -1, always.
Drop autocmd neighbor detection in favor of simple extension matching.
Enable disabling heuristics on a per-filetype basis.
Bug fixes and assorted tweaks.
sleuth.zip 1.3 2022-01-12 7.0 Tim Pope Support EditorConfig and modelines.
Detect 'textwidth' and 'fixendofline' in EditorConfig and modelines.
Show reason for each option in :verbose Sleuth.
Assorted performance improvements.
Use most common indent increment, rather than smallest, as 'shiftwidth'.
Leverage 'shiftwidth' of 0 to delegate to 'tabstop'.
Limit neighbor detection to containing and parent directory.
Fix neighbor detection for *.h files.
Skip over heredocs in shell scripts, Perl, PHP, and Ruby.
Limit supported 'shiftwidth' values to 2, 3, and multiples of 4.
Provide option to opt out of :filetype indent on.
sleuth.zip 1.2 2021-04-02 7.0 Tim Pope Add option to limit number of other files checked, defaulting to 20.
Add global and local options to disable automatic detection.
Provide :Sleuth for manual detection.
Add indicator for flagship.vim.
Skip over Python style triple quoted strings.
Skip over XML/HTML style comments.
Skip over backtick quoted strings in Go files only.
Avoid activating on help buffers.
Check vimrc when sleuthing under Vim filetype.
Disallow odd 'shiftwidth' values greater than 3.
sleuth.zip 1.1 2013-01-21 7.0 Tim Pope Support custom tabstop in pure tabs files.
Fix performance issue with globbing for other files.
Skip over POD comments.
sleuth.zip 1.0 2012-12-30 7.0 Tim Pope Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github