On Thursday, October 25, 2012 12:35:57 PM UTC-5, analogsix wrote:
> Thanks guys, 
> 
> tabstop did it. I read the help text on 
> :tabstop, :softtabstop, :expandtab, :shiftwidth
> 
> I'll list a description of each according to how I understand it. Can you 
> kindly correct my understanding where I'm mistaken?
> 
> :set tabstop=#
> also known as a hard tab. Configuring this setting specifies the number of 
> <space> characters per <tab> character inputted in insert mode.
> 

No, this option controls how many spaces are DISPLAYED for a hard tab in the 
text. It has nothing to do with what characters are actually inserted into the 
text when you press your <tab> key.

> :set softtabstop=#
> also known as a soft tab (default is 0 which means it is a disabled setting). 
> However if a nonzero number is set that is greater than :tabstop then <Tab>s 
> and <Backspace>s in insert mode will be the equivalent to inserting a number 
> of hard <Tab>s (as specified by :tabstop) as well as <space>s so that the 
> total number of spaces is equivalent to what was specified in :softtabstop. 
> Hence when softtabstop is 
> 

This option also affects autoindent. Autoindent always works in multiples of 
your 'shiftwidth' option.

> :set expandtab 
> boolean setting (default is off). 
> In insert mode, this setting uses the appropriate number of spaces (as 
> specified when ':set autoindent' as well as the ':set shiftwidth=#' option is 
> set) to insert tabs. The number of spaces is specified by 'shiftwidth'.
> 

When this setting is on, pressing <tab> in insert mode actually inserts spaces 
instead of tabs.

> :set shiftwidth
> (default is 8)
> # of spaces to use for each step of autoindent (i.e. 'cindent', '>>', and 
> '<<')

A good example of how these play together is the Vim source code, which if 
memory serves uses:

shiftwidth=4
tabstop=8
softtabstop=4
noexpandtab

Pressing tab once on an empty line inserts 4 spaces. Pressing it again replaces 
the 4 spaces with a single hard tab. A third time gives you a single hard tab 
followed by 4 spaces. A fourth time gives you 2 hard tabs, etc. Automatic 
indentation with cindent, autoindent, etc. inserts enough tabs, possibly 
followed by 4 spaces, to reach the appropriate multiple of 'shiftwidth'.

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to