IndentTab : Use tabs for indent at the beginning, spaces for alignment in the rest of a line
| script karma
Downloaded by 417
Comments, bugs, improvements
script versions (upload new version)
This plugin allows you to use your normal tab settings ('tabstop',
'smarttabstop', 'expandtab') for the beginning of the line (up to the first
non-whitespace character), and have <Tab> expanded to the appropriate number
of spaces (i.e. like :set expandtab) anywhere else. This effectively
distinguishes "indenting" from "alignment"; the characters inserted by <Tab>
depend on the local context.
HOW IT WORKS
This plugin overrides the default behavior of the <Tab> and <BS> keys in
- ctab.vim (vimscript #231) by Michael Geddes exists since 2002. It also
offers global and buffer-local mappings, but uses a slightly different
approach, does not handle comment[prefixes], instead has some
filetype-specific stuff. It also remaps <CR>, o and O, and additionally
offers a :RetabIndent command.
The indent tab can be en-/disabled globally or only for a particular buffer.
call IndentTab#Set( isTurnOn, isGlobal )
You probably want to define your own mappings / commands for that, or do this
for certain filetypes only.
<Tab> Uses normal tab settings at the beginning of the line
(before the first non-whitespace character), and
inserts spaces otherwise.
<BS> Uses normal tab settings to delete tabs at the
beginning of the line; elsewhere it also removes
"space-expanded" tabs as if 'softtabstop' were
The exact circumstances under which the normal tab
settings apply are configured by the
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
To uninstall, use the :RmVimball command.
- Requires Vim 7.0 or higher.
- Requires the ingo-library.vim plugin (vimscript #4433), version 1.005 or
For a permanent configuration, put the following commands into your vimrc:
Determine where the buffer's indent settings are applied. Elsewhere, spaces
are used for alignment. Comma-separated list of the following values:
indent: Initial whitespace at the beginning of a line.
commentprefix: Initial whitespace after a comment prefix, in case the line
begins with the comment prefix, not any indent.
comment: Inside comments, as determined by syntax highlighting.
string: Inside strings, as determined by syntax highlighting.
let g:IndentTab_scopes = 'indent,commentprefix,string'
To determine whether the 'indenttab' setting is active in the current buffer,
you can call IndentTab#Info#IndentTab(), which yields a boolean value. This
can be used as a replacement for a hypothetical ":set indenttab?", e.g. in a
Plugins like SuperTab (vimscript #1643) overload the <Tab> key with
insert-mode completion and fall back to inserting a literal <Tab> character.
This is in conflict with this plugin's maps. To integrate, set
let g:IndentTab_IsSuperTab = 1
This avoids that IndentTab overrides the <Tab> mapping. Inside SuperTab,
instead of returning a literal <Tab>, you need to use the function
Click on the package to download.
ip used for rating: 188.8.131.52
||- The scope tests that use syntax highlighting can be wrong when there's no separating whitespace. To properly detect the scope, we need to first insert whitespace, then perform the scope tests that use syntax highlighting.
- FIX: In IndentTab#SuperTabIntegration#GetExpr(), prefer buffer-local setting over global one to correctly implement the precedence.
- Add dependency to ingo-library (vimscript #4433).