r1238 - in /trunk/packages/vim-scripts: debian/changelog debian/patches/00list debian/patches/detectindent_fix.dpatch debian/vim-scripts.status doc/detectindent.txt html/index.html html/plugin_detectindent.vim.html plugin/detectindent.vim
jamessan at users.alioth.debian.org
jamessan at users.alioth.debian.org
Tue Apr 8 15:29:52 UTC 2008
Author: jamessan
Date: Tue Apr 8 15:29:51 2008
New Revision: 1238
URL: http://svn.debian.org/wsvn/pkg-vim/?sc=1&rev=1238
Log:
New addons:
- DetectIndent: Automatically detect indent settings (Closes: #471890)
Added:
trunk/packages/vim-scripts/debian/patches/detectindent_fix.dpatch
trunk/packages/vim-scripts/doc/detectindent.txt
trunk/packages/vim-scripts/html/plugin_detectindent.vim.html
trunk/packages/vim-scripts/plugin/detectindent.vim
Modified:
trunk/packages/vim-scripts/debian/changelog
trunk/packages/vim-scripts/debian/patches/00list
trunk/packages/vim-scripts/debian/vim-scripts.status
trunk/packages/vim-scripts/html/index.html
Modified: trunk/packages/vim-scripts/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/changelog?rev=1238&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/changelog (original)
+++ trunk/packages/vim-scripts/debian/changelog Tue Apr 8 15:29:51 2008
@@ -8,6 +8,8 @@
(Closes: #465330)
* Updated addons:
- xmledit
+ * New addons:
+ - DetectIndent: Automatically detect indent settings (Closes: #471890)
-- James Vega <jamessan at debian.org> Tue, 05 Feb 2008 17:06:54 -0500
Modified: trunk/packages/vim-scripts/debian/patches/00list
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/patches/00list?rev=1238&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/patches/00list (original)
+++ trunk/packages/vim-scripts/debian/patches/00list Tue Apr 8 15:29:51 2008
@@ -13,3 +13,4 @@
sokoboan_path
usagestring-dtd2vim
vimplate_debian-path
+detectindent_fix
Added: trunk/packages/vim-scripts/debian/patches/detectindent_fix.dpatch
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/patches/detectindent_fix.dpatch?rev=1238&op=file
==============================================================================
--- trunk/packages/vim-scripts/debian/patches/detectindent_fix.dpatch (added)
+++ trunk/packages/vim-scripts/debian/patches/detectindent_fix.dpatch Tue Apr 8 15:29:51 2008
@@ -1,0 +1,44 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## detectindent_fix.dpatch by Antonio Terceiro <terceiro at softwarelivre.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+ at DPATCH@
+diff -urNad vim-scripts.svn~/plugin/detectindent.vim vim-scripts.svn/plugin/detectindent.vim
+--- vim-scripts.svn~/plugin/detectindent.vim 2008-03-20 19:12:27.000000000 -0300
++++ vim-scripts.svn/plugin/detectindent.vim 2008-03-30 18:34:28.677760572 -0300
+@@ -86,7 +86,7 @@
+ if l:has_leading_tabs && ! l:has_leading_spaces
+ " tabs only, no spaces
+ set noexpandtab
+- if exists("g:detectindent_preferred_tabsize")
++ if exists("g:detectindent_preferred_indent")
+ let &shiftwidth = g:detectindent_preferred_indent
+ let &tabstop = g:detectindent_preferred_indent
+ endif
+@@ -95,6 +95,8 @@
+ " spaces only, no tabs
+ set expandtab
+ let &shiftwidth = l:shortest_leading_spaces_run
++ let &tabstop = l:shortest_leading_spaces_run
++ let &softtabstop = l:shortest_leading_spaces_run
+
+ elseif l:has_leading_spaces && l:has_leading_tabs
+ " spaces and tabs
+@@ -109,12 +111,14 @@
+ else
+ let &tabstop = 8
+ endif
++ let &softtabstop = &tabstop
+
+ else
+ " no spaces, no tabs
+- if exists("g:detectindent_preferred_tabsize")
++ if exists("g:detectindent_preferred_indent")
+ let &shiftwidth = g:detectindent_preferred_indent
+ let &tabstop = g:detectindent_preferred_indent
++ let &softtabstop = g:detectindent_preferred_indent
+ endif
+ if exists("g:detectindent_preferred_expandtab")
+ set expandtab
Modified: trunk/packages/vim-scripts/debian/vim-scripts.status
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/vim-scripts.status?rev=1238&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/vim-scripts.status (original)
+++ trunk/packages/vim-scripts/debian/vim-scripts.status Tue Apr 8 15:29:51 2008
@@ -388,6 +388,16 @@
email: benw at plasticboy.com
license: no license
version: 6
+
+script_name: plugin/detectindent.vim
+addon: detectindent
+description: detects the current indentation of files
+script_url: http://www.vim.org/scripts/script.php?script_id=1171
+author: Ciaran McCreesh
+author_url: http://www.vim.org/account/profile.php?user_id=4078
+email: ciaran.mccreesh at googlemail.com
+license: Vim's license [4], see below
+version: 1.0
--
Added: trunk/packages/vim-scripts/doc/detectindent.txt
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/doc/detectindent.txt?rev=1238&op=file
==============================================================================
--- trunk/packages/vim-scripts/doc/detectindent.txt (added)
+++ trunk/packages/vim-scripts/doc/detectindent.txt Tue Apr 8 15:29:51 2008
@@ -1,0 +1,40 @@
+*detectindent.txt* The Detect Indent Plugin 1.0, Jan 04, 2005
+
+Author: Ciaran McCreesh <ciaranm at gentoo dot org>
+
+==============================================================================
+1. Contents *detectindent* *detectindent-contents*
+
+ 1. Contents |detectindent-contents|
+ 2. :DetectIndent Command |:DetectIndent|
+ Settings |detectindent-settings|
+ 3. Uptime ChangeLog |uptime-changelog|
+
+==============================================================================
+2. :DetectIndent Command *:DetectIndent*
+
+ The :DetectIndent command tries to intelligently set the 'shiftwidth',
+ 'expandtab' and 'tabstop' options based upon the existing settings in
+ use in the active file.
+
+ Settings *detectindent-settings*
+
+ When the correct value for 'expandtab' cannot be determined, it will
+ usually retain its existing value. To specify that 'expandtab' should
+ be used where autodetection is impossible, set: >
+ :let g:detectindent_preferred_expandtab = 1
+< in your |vimrc| file.
+
+ To set a preferred value for 'shiftwidth' and 'tabstop' when they
+ cannot be automatically detected, set: >
+ :let g:detectindent_preferred_indent = 4
+< in your |vimrc| file.
+
+==============================================================================
+3. DetectIndent ChangeLog *detectindent-changelog*
+
+ v1.0 (20050105)
+ * initial release after discussion on irc.freenode.net:#vim
+
+==============================================================================
+vim:tw=78:ts=8:ft=help
Modified: trunk/packages/vim-scripts/html/index.html
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/html/index.html?rev=1238&op=diff
==============================================================================
--- trunk/packages/vim-scripts/html/index.html (original)
+++ trunk/packages/vim-scripts/html/index.html Tue Apr 8 15:29:51 2008
@@ -28,6 +28,7 @@
<li><a href="plugin_calendar.vim.html">plugin/calendar.vim.html</a></li>
<li><a href="plugin_cvsmenu.vim.html">plugin/cvsmenu.vim.html</a></li>
<li><a href="plugin_debPlugin.vim.html">plugin/debPlugin.vim.html</a></li>
+ <li><a href="plugin_detectindent.vim.html">plugin/detectindent.vim.html</a></li>
<li><a href="plugin_gnupg.vim.html">plugin/gnupg.vim.html</a></li>
<li><a href="plugin_info.vim.html">plugin/info.vim.html</a></li>
<li><a href="plugin_lbdbq.vim.html">plugin/lbdbq.vim.html</a></li>
@@ -48,7 +49,7 @@
<li><a href="syntax_mkd.vim.html">syntax/mkd.vim.html</a></li>
</ul>
<p>
- Page generated on Wed, 13 Feb 2008 14:44:45 -0500
+ Page generated on Tue, 08 Apr 2008 11:26:48 -0400
.
</p>
</body>
Added: trunk/packages/vim-scripts/html/plugin_detectindent.vim.html
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/html/plugin_detectindent.vim.html?rev=1238&op=file
==============================================================================
--- trunk/packages/vim-scripts/html/plugin_detectindent.vim.html (added)
+++ trunk/packages/vim-scripts/html/plugin_detectindent.vim.html Tue Apr 8 15:29:51 2008
@@ -1,0 +1,272 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+
+<head>
+ <link rel="Stylesheet" type="text/css" href="/css/style.css" >
+ <title>DetectIndent - Automatically detect indent (expandtab, shiftwidth, tabstop) settings : vim online</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <meta name="KEYWORDS" content="Vim, Vi IMproved, text editor, home, documentation, tips, scripts, news">
+ <link rel="shortcut icon" type="image/x-icon" href="/images/vim_shortcut.ico">
+</head>
+
+<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#ffffff">
+
+<!-- HEADER, SPONSOR IMAGE, VIM IMAGE AND BOOK AD -->
+<table width="100%" cellpadding="0" cellspacing="0" border="0" bordercolor="red">
+ <tr>
+ <td colspan="4" class="lightbg"><img src="/images/spacer.gif" width="1" height="5" alt=""></td>
+ </tr>
+ <tr>
+ <td class="lightbg"> </td>
+ <td class="lightbg" align="left"><a href="/sponsor/index.php"><img src="/images/sponsorvim.gif" alt="sponsor Vim development" border="0"></a></td>
+ <td class="lightbg" align="center"><a href="/index.php"><img src="/images/vim_header.gif" border="0" alt="Vim logo"></a></td>
+ <td class="lightbg" align="right"><a href="http://iccf-holland.org/click5.html"><img src="/images/buyhelplearn.gif" alt="Vim Book Ad" border="0"></a></td>
+ </tr>
+ <tr>
+ <td colspan="4" class="lightbg"><img src="/images/spacer.gif" width="1" height="5" alt=""></td>
+ </tr>
+ <tr>
+ <td colspan="4" class="darkbg"><img src="/images/spacer.gif" width="1" height="10" alt=""></td>
+ </tr>
+</table>
+<!-- THE PAGE BODY: BETWEEN HEADER AND FOOTER -->
+
+<table cellpadding="0" cellspacing="0" border="0" width="100%">
+ <col width="180">
+ <col width="1">
+
+ <tr valign="top">
+ <td class="sidebar">
+ <table width="180" cellpadding="4" cellspacing="0" border="0">
+ <tr valign="top">
+ <td class="sidebar">
+
+<!-- INCLUDE THE PAGE NAVIGATION -->
+<table width="100%" cellpadding="0" cellspacing="0" border="0" bordercolor="red">
+ <tr>
+ <td><small>not logged in (<a href="/login.php">login</a>)</small></td>
+ </tr>
+ <tr>
+ <td><img src="/images/spacer.gif" alt="" border="0" width="1" height="1"></td>
+ </tr>
+ <tr>
+ <td class="darkbg"><img src="/images/spacer.gif" alt='' border="0" height="3"></td>
+ </tr>
+ <tr>
+ <td><img src="/images/spacer.gif" alt="" border="0" width="1" height="2"></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/index.php">Home</a></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/search.php">Search</a></td>
+ </tr>
+ <tr>
+ <td><img src="/images/spacer.gif" alt="" border="0" width="1" height="7"></td>
+ </tr>
+ <tr>
+ <td class="checker"><img src="/images/spacer.gif" alt='' border="0" height="1"></td>
+ </tr>
+ <tr>
+ <td><img src="/images/spacer.gif" alt="" border="0" width="1" height="7"></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/about.php">About Vim</a></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/community.php">Community</a></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/news/news.php">News</a></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/sponsor/index.php">Sponsoring</a></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/trivia.php">Trivia</a></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/docs.php">Documentation</a></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/download.php">Download</a></td>
+ </tr>
+ <tr>
+ <td><img src="/images/spacer.gif" alt="" border="0" width="1" height="7"></td>
+ </tr>
+ <tr>
+ <td class="checker"><img src="/images/spacer.gif" alt='' border="0" height="1"></td>
+ </tr>
+ <tr>
+ <td><img src="/images/spacer.gif" alt="" border="0" width="1" height="7"></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/scripts/index.php">Scripts</a></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/tips/index.php">Tips</a></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/account/index.php">My Account</a></td>
+ </tr>
+ <tr>
+ <td><img src="/images/spacer.gif" alt="" border="0" width="1" height="7"></td>
+ </tr>
+ <tr>
+ <td class="checker"><img src="/images/spacer.gif" alt='' border="0" height="1"></td>
+ </tr>
+ <tr>
+ <td><img src="/images/spacer.gif" alt="" border="0" width="1" height="7"></td>
+ </tr>
+ <tr>
+ <td class="sidebarheader"><a href="/huh.php">Site Help</a></td>
+ </tr>
+</table>
+
+ <table width="172" cellpadding="0" cellspacing="0" border="0">
+ <tr><td><img src="/images/spacer.gif" alt="" border="0" width="1" height="8"></td></tr>
+ <tr><td class="darkbg"><img src="/images/spacer.gif" width="1" height="3" alt=""></td></tr>
+ </table>
+ <br>
+
+<!-- INCLUDE THE PAGE SIDEBAR TEXT -->
+
+
+ </td>
+ </tr>
+ </table>
+ </td>
+
+ <td class="darkbg"><img src="/images/spacer.gif" width="1" height="1" border="0" alt=""><br></td>
+ <td>
+ <table width="100%" cellpadding="10" cellspacing="0" border="0" bordercolor="red">
+ <tr>
+ <td valign="top">
+
+<span class="txth1">DetectIndent : Automatically detect indent (expandtab, shiftwidth, tabstop) settings</span>
+
+<br>
+<br>
+
+<!-- karma table -->
+<table cellpadding="4" cellspacing="0" border="1" bordercolor="#000066">
+<tr>
+ <td class="lightbg"><b> script karma </b></td>
+ <td>
+ Rating <b>41/16</b>,
+ Downloaded by 495 </td>
+</tr>
+</table>
+<p>
+
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td class="prompt">created by</td></tr>
+<tr><td><a href="/account/profile.php?user_id=4078">Ciaran McCreesh</a></td></tr>
+<tr><td> </td></tr>
+<tr><td class="prompt">script type</td></tr>
+<tr><td>utility</td></tr>
+<tr><td> </td></tr>
+<tr><td class="prompt">description</td></tr>
+<tr><td>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.
<br>
<br>Usage:
<br>
<br>:DetectIndent
<br>
<br>May also be used in an autocommand, for example:
<br>
<br>:autocmd BufReadPost * :DetectIndent
<br>
<br>Options:
<br>
<br>To prefer 'expandtab' to 'noexpandtab' when no detection is possible:
<br>:let g:detectindent_preferred_expandtab = 1
<br>
<br>To specify a preferred indent level when no detection is possible:
<br>:let g:detectindent_preferred_indent = 4
<br>
<br>Notes:
<br>
<br>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...</td></tr>
+<tr><td> </td></tr>
+<tr><td class="prompt">install details</td></tr>
+<tr><td>Place in ~/.vim/plugin/ and ~/.vim/doc/</td></tr>
+<tr><td> </td></tr>
+</table>
+
+<!-- rating table -->
+<form name="rating">
+<input type="hidden" name="script_id" value="1171">
+<table cellpadding="4" cellspacing="0" border="1" bordercolor="#000066">
+<tr>
+ <td class="lightbg"><b>rate this script</b></td>
+ <td valign="middle">
+ <input type="radio" name="rating" value="life_changing">Life Changing
+ <input type="radio" name="rating" value="helpful">Helpful
+ <input type="radio" name="rating" value="unfulfilling">Unfulfilling
+ <input type="submit" value="rate">
+ </td>
+</tr>
+</table>
+</form>
+<span class="txth2">script versions</span> (<a href="add_script_version.php?script_id=1171">upload new version</a>)
+<p>
+Click on the package to download.
+<p>
+
+<table cellspacing="2" cellpadding="4" border="0" width="100%">
+<tr class='tableheader'>
+ <th valign="top">package</th>
+ <th valign="top">script version</th>
+ <th valign="top">date</th>
+ <th valign="top">Vim version</th>
+ <th valign="top">user</th>
+ <th valign="top">release notes</th>
+</tr>
+<tr>
+ <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=3743">detectindent-1.0.tar.bz2</a></td>
+ <td class="rowodd" valign="top" nowrap><b>1.0</b></td>
+ <td class="rowodd" valign="top" nowrap><i>2005-01-03</i></td>
+ <td class="rowodd" valign="top" nowrap>6.0</td>
+ <td class="rowodd" valign="top"><i><a href="/account/profile.php?user_id=4078">Ciaran McCreesh</a></i></td>
+ <td class="rowodd" valign="top" width="2000">Initial upload</td>
+</tr>
+</table>
+<!-- finish off the framework -->
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+
+<!-- END OF THE PAGE BODY: BETWEEN HEADER AND FOOTER -->
+
+<table width="100%" cellpadding="0" cellspacing="0" border="0" bordercolor="red">
+ <tr><td colspan="4"><img src="/images/spacer.gif" width="1" height="5" alt=""></td></tr>
+ <tr><td colspan="4" bgcolor="#000000"><img src="/images/spacer.gif" height="2" width="1" alt=""></td></tr>
+ <tr><td colspan="4"><img src="/images/spacer.gif" width="1" height="5" alt=""></td></tr>
+ <tr>
+ <td><img src="/images/spacer.gif" width="5" height="1" alt=""></td>
+
+ <td align="left" valign="top"><small>
+ If you have questions or remarks about this site, visit the
+ <a href="http://vimonline.sf.net">vimonline development</a> pages.
+ Please use this site responsibly.
+ <br>
+
+ Questions about <a href="http://www.vim.org/about.php">Vim</a> should go
+ to the <a href="http://www.vim.org/maillist.php">maillist</a>.
+ Help Bram <a href="http://iccf-holland.org/">help Uganda</a>.
+ </small>
+
+
+
+ <!-- Start of StatCounter Code -->
+ <script type="text/javascript" language="javascript">
+ var sc_project=1417324;
+ var sc_invisible=1;
+ var sc_partition=11;
+ var sc_security="d41633bc";
+ </script>
+
+ <script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><a href="http://www.statcounter.com/" target="_blank"><img src="http://c12.statcounter.com/counter.php?sc_project=1417324&java=0&security=d41633bc&invisible=0" alt="free tracking" border="0"></a> </noscript>
+ <!-- End of StatCounter Code -->
+ </td>
+
+ <td align="right" valign="top">
+ <a href="http://sourceforge.net" rel="nofollow"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=8&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a>
+ </td>
+
+ <td><img src="/images/spacer.gif" width="5" height="1" alt=""></td>
+ </tr>
+
+
+ <tr><td colspan="4"><img src="/images/spacer.gif" width="1" height="5" alt=""></td>
+
+ </tr>
+</table>
+
+</body>
+</html>
+
Added: trunk/packages/vim-scripts/plugin/detectindent.vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/plugin/detectindent.vim?rev=1238&op=file
==============================================================================
--- trunk/packages/vim-scripts/plugin/detectindent.vim (added)
+++ trunk/packages/vim-scripts/plugin/detectindent.vim Tue Apr 8 15:29:51 2008
@@ -1,0 +1,127 @@
+" Name: detectindent (global plugin)
+" Version: 1.0
+" Author: Ciaran McCreesh <ciaranm at gentoo.org>
+" Updates: http://dev.gentoo.org/~ciaranm/vim/
+" Purpose: Detect file indent settings
+"
+" License: You may redistribute this plugin under the same terms as Vim
+" itself.
+"
+" Usage: :DetectIndent
+"
+" " to prefer expandtab to noexpandtab when detection is
+" " impossible:
+" :let g:detectindent_preferred_expandtab = 1
+"
+" " to set a preferred indent level when detection is
+" " impossible:
+" :let g:detectindent_preferred_indent = 4
+"
+" Requirements: Untested on Vim versions below 6.2
+
+fun! <SID>IsCommentStart(line)
+ " &comments isn't reliable
+ if &ft == "c" || &ft == "cpp"
+ return -1 != match(a:line, '/\*')
+ else
+ return 0
+ endif
+endfun
+
+fun! <SID>IsCommentEnd(line)
+ if &ft == "c" || &ft == "cpp"
+ return -1 != match(a:line, '\*/')
+ else
+ return 0
+ endif
+endfun
+
+fun! <SID>DetectIndent()
+ let l:has_leading_tabs = 0
+ let l:has_leading_spaces = 0
+ let l:shortest_leading_spaces_run = 0
+ let l:longest_leading_spaces_run = 0
+
+ let l:idx_end = line("$")
+ let l:idx = 1
+ while l:idx <= l:idx_end
+ let l:line = getline(l:idx)
+
+ " try to skip over comment blocks, they can give really screwy indent
+ " settings in c/c++ files especially
+ if <SID>IsCommentStart(l:line)
+ while l:idx <= l:idx_end && ! <SID>IsCommentEnd(l:line)
+ let l:line = getline(l:idx)
+ let l:idx = l:idx + 1
+ endwhile
+ let l:idx = l:idx + 1
+ continue
+ endif
+
+ let l:leading_char = strpart(l:line, 0, 1)
+
+ if l:leading_char == "\t"
+ let l:has_leading_tabs = 1
+
+ elseif l:leading_char == " "
+ " only interested if we don't have a run of spaces followed by a
+ " tab.
+ if -1 == match(l:line, '^ \+\t')
+ let l:has_leading_spaces = 1
+ let l:spaces = strlen(matchstr(l:line, '^ \+'))
+ if l:shortest_leading_spaces_run == 0 ||
+ \ l:spaces < l:shortest_leading_spaces_run
+ let l:shortest_leading_spaces_run = l:spaces
+ endif
+ if l:spaces > l:longest_leading_spaces_run
+ let l:longest_leading_spaces_run = l:spaces
+ endif
+ endif
+
+ endif
+
+ let l:idx = l:idx + 1
+ endwhile
+
+ if l:has_leading_tabs && ! l:has_leading_spaces
+ " tabs only, no spaces
+ set noexpandtab
+ if exists("g:detectindent_preferred_tabsize")
+ let &shiftwidth = g:detectindent_preferred_indent
+ let &tabstop = g:detectindent_preferred_indent
+ endif
+
+ elseif l:has_leading_spaces && ! l:has_leading_tabs
+ " spaces only, no tabs
+ set expandtab
+ let &shiftwidth = l:shortest_leading_spaces_run
+
+ elseif l:has_leading_spaces && l:has_leading_tabs
+ " spaces and tabs
+ set noexpandtab
+ let &shiftwidth = l:shortest_leading_spaces_run
+
+ " mmmm, time to guess how big tabs are
+ if l:longest_leading_spaces_run < 2
+ let &tabstop = 2
+ elseif l:longest_leading_spaces_run < 4
+ let &tabstop = 4
+ else
+ let &tabstop = 8
+ endif
+
+ else
+ " no spaces, no tabs
+ if exists("g:detectindent_preferred_tabsize")
+ let &shiftwidth = g:detectindent_preferred_indent
+ let &tabstop = g:detectindent_preferred_indent
+ endif
+ if exists("g:detectindent_preferred_expandtab")
+ set expandtab
+ endif
+
+ endif
+endfun
+
+command! -nargs=0 DetectIndent call <SID>DetectIndent()
+
More information about the pkg-vim-maintainers
mailing list