Sunday, November 1, 2015

Re: conflagration between expantab and softtabstop

2015-11-02 6:03 GMT+03:00 toothpik <toothpik6@gmail.com>:
> in setting softtabstop to 4, things are fine, unless and until I want to
> start entering actual tab characters in a module which gets parsed
> using tabs as delimiters -- my thought was that by setting noexpandtab
> any time I hit the tab key in insert mode, a tab would be inserted
>
> that is not what happens
>
> with softtabstop set to 4 and set noexpandtab, in insert mode on a new
> line, when I enter a single character followed by a tab, 3 spaces are
> inserted
>
> to repeat, even though I have set noexpandtab, 3 spaces are inserted
> when I hit the tab key
>
> I find this unexpected -- history dictates when I am having unexpected
> results it is because I don't fully understand what I am doing, so
> please, ppl, educate me -- why are spaces inserted with noexpandtab
> set?
>
> do I have to set softtabstop to zero whenever I want noexpandtab?
>
> would not the expected behavior be to honor noexpandtab?

There is such a thing as "mixed tabs/spaces indentation": specifically
with tabstop=8 shiftwidth=4 softtabstop=4 first level of indent is
four spaces, second is a tab, third is a tab and four spaces, etc.
(You may see an example in Vim sources, hopefully it is one of the
*very* rare exceptions: normal people use either only tabs or only
spaces.) To disable the behaviour all you need is to set tabstop
option to the same value as softtabstop, then expandtab will work as
expected. I consider it a good practice to set tabstop, softtabstop
and shiftwidth *all* to one value (4 in most cases).

As an alternative you may just use <C-v><Tab> in place of <Tab>: this
will insert tab character regardless of any options: tab character
will be inserted with <C-v> even with `set expandtab`.

>
> --
> --
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: