Skip to content

tpope/vim-sleuth

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

The goal here is to skip modelines if 'nomodeline' is set for the
current buffer (e.g., the ftplugin disables it), but not if it was set
globally (e.g., the system vimrc sets it).  The existing logic
successfully rejects `:setglobal nomodeline`, but fails to reject
`:set nomodeline`, since that sets both the local and global option.  So
lets also reject any local option that was set in the exact same place
as the global option.

All of this can be avoided if you leave 'modeline' enabled and instead
`:set modelines=0`.  Thus this is my recommended way to disable
modelines.
1cc4557

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
November 12, 2019 19:01
doc
January 10, 2023 14:13
December 30, 2012 18:16

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. Modelines and EditorConfig are also consulted, adding 'tabstop', 'textwidth', 'endofline', 'fileformat', 'fileencoding', and 'bomb' to the list of supported options.

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

  • If your file is consistently indented with hard tabs, 'shiftwidth' will be set to your 'tabstop'. Otherwise, a 'tabstop' of 8 is enforced, unless another value is explicitly declared in a modeline or EditorConfig.

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.