sponsor Vim development Vim logo Vim Book Ad

DetectIndent : Automatically detect indent (expandtab, shiftwidth, tabstop) settings

 script karma  Rating 223/77, Downloaded by 2703  Comments, bugs, improvements  Vim wiki

created by
Ciaran McCreesh
 
script type
utility
 
description
This script provides a command which will attempt to guess the correct indent settings for an open file, for use when there is no modeline available. Note that this is a pure vim implementation, and doesn't require any external applications or interpreters.

Usage:

:DetectIndent

May also be used in an autocommand, for example:

:autocmd BufReadPost * :DetectIndent

Options:

To prefer 'expandtab' to 'noexpandtab' when no detection is possible:
:let g:detectindent_preferred_expandtab = 1

To specify a preferred indent level when no detection is possible:
:let g:detectindent_preferred_indent = 4

Notes:

Detection is by no means perfect. It won't work if files use especially perverse combinations of spaces and tabs, or weird tab widths. Bug reports and patches encouraged...

Keeping things up to date on vim.org is a nuisance. For the latest version, visit:

    http://github.com/ciaranm/detectindent
 
install details
Place in ~/.vim/plugin/ and ~/.vim/doc/
 

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
detectindent-1.0.tar.bz2 1.0 2005-01-03 6.0 Ciaran McCreesh 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