GuessIndent : Indentation guessing plugin
| script karma
Downloaded by 305
Comments, bugs, improvements
script versions (upload new version)
This plugin is based on the DetectIndent plugin by Ciaran McCreesh.
Many thanks to him for inspiration and code.
Source code and development is at https://github.com/ogier/guessindent
The :GuessIndent command tries to determine whether the active file
uses tabs or spaces for indentation as a convention. If the file
appers to use spaces for indentation, the plugin will try to
intelligently set the 'shiftwidth' and 'softtabstop' options.
You can run this command automatically every time a file is loaded.
To do that, include the following in your ~/.vimrc file:
autocmd BufReadPost * :GuessIndent
If at least 3/4 of the lines in the active file appear to use spaces
for indentation, then 'expandtab' will be set. If at least 3/4 of
the lines in the active file use tabs for indentation, 'noexpandtab'
will be set. If no tabs or spaces are used (for example if the file
is new) then the command does nothing. If there is a roughly even mix
then the file is considered to be ambiguous.
If the file sometimes uses spaces and sometimes uses tabs for
indentation ambiguously, spaces are arbitrarily chosen as the
indentation method and 'expandtab' is set. If you prefer to use
tabs in this case and set 'noexpandtab', include the following
in your ~/.vimrc file:
let g:guessindent_prefer_tabs = 1
For performance reasons, :GuessIndent reads a limited number of
lines from the active file. The default is currently to read a
maximum of 1024 lines. To change this maximum, include the
following in your ~/.vimrc file:
let g:guessindent_max_lines_to_analyse = 2048
This plugin is distributed under the same terms as vim istelf.
Contributions are welcome.
|Unzip and install to ~/.vim/plugin and ~/.vim/doc. You may need to run :Helptags before you can see the documentation with :help GuessIndent.|
Click on the package to download.
ip used for rating: 188.8.131.52