Status: summary.
State: draft,part.
Detailed description: Some tables for illustrate <Tab>'s handling in vim. See vim help for details.
Tabs in vim {{{ 'sts' and 'sta' options {{{ Following options affect <Tab>s and indents: 'tabstop' 'ts' 'shiftwidth' 'sw' 'softtabstop' 'sts' 'smarttab' 'sta' 'expandtab' 'et' 'sw' and 'ts' define standard vim operations behavior, they are not switches for some features (hence they're always set and always used). But 'sts' and 'sta' enables additional features, which affect (change) some vim operations behavior (hence, they can be unset to turn feature off). Table below shows what option will be used to determine how many positions insert or delete during some editing operations depending on activated modes: both 'sts' and 'sta' are off (default), 'sts' set, 'sta' set and both 'sts' and 'sta' set. When editing operation insert less (or more) positions, than real <Tab> counts for, mix from spaces and real <Tab>s are used. +--------------------------+-------------------------------------------+ | Operation | Will be inserted .. positions | | +------+-----------+-----------+------------+ | | | +sts | +sta | +sts +sta | +--------------------------+------+-----------+-----------+------------+ | Use >> , etc | sw | sw | sw | sw | +--------------------------+------+-----------+-----------+------------+ | Type <Tab> or <BS> | ts | sts (mix) | | | | + + +-----------+------------+ | at the start of line | | | sw (mix) | sw (mix) | | + + +-----------+------------+ | in other places | | | ts | sts (mix) | +--------------------------+------+-----------+-----------+------------+ | Real <Tab> length | ts | ts | ts | ts | +--------------------------+------+-----------+-----------+------------+ }}} ':retab' and changing 'ts' option value {{{ 'ts' option changes real tabstop, but does not change text. Hence, indents, which made according to old tabstop, probably will be messed (i.e there will be visible changes in text), but actual file remains untouched. So, using 'undo' after changing 'ts' has no sense. :retab command changes both 'ts' option and text according to new 'ts' value in such way, that all indents remain the same (there will be no visible changes), though actual file will be changed (to preserve visible indents :retab pads them, if necessary, with spaces). So, using 'undo' after :retab recover text to previous state, but not recover 'ts' to previous value, hence indents may be messed (like after you change only 'ts') and to recover visible text state you need set 'ts' to previous value. Table below summarizes that. +-------------------+---------------+-----------+ | | Change 'ts' | :retab | +-------------------+---------------+-----------+ | 'ts' changed? | yes | yes | +-------------------+---------------+-----------+ | File changed? | no | yes | +-------------------+---------------+-----------+ | Visible changes? | yes | no | +-------------------+---------------+-----------+ }}} }}}
Комментариев нет:
Отправить комментарий