Page 1 of 1

tabstop vs. tabwidth

Posted: Thu Jun 07, 2018 12:56 am
by lovelyshell
When I pressed tab key in insert mode, I found vim forward the cursor to the nearest column aligned on value tabstop . And I guess this is how tabstop got its name.

But why does vim design tab behavior like this, why not simply forward cursor by tabwidth (rather than named tabstop)columns discarding alignment? This seems to be the traditional behavior of tab key.

Re: tabstop vs. tabwidth

Posted: Thu Jun 07, 2018 1:06 am
by iansjack
My experience of the TAB key is that, in almost all software, it behaves as you describe - i.e. moves to fixed columns rather than moving by a fixed amount. It's the way that tabs on old-fashioned typewriters worked. (Tab being short for tabulator - i.e. something designed to produce tables.)

This is exactly what you want in, for example, a text editor where you want the starts of lines to be aligned or if you are creating tables where the columns need to be aligned..

Re: tabstop vs. tabwidth

Posted: Thu Jun 07, 2018 1:52 am
by lovelyshell
iansjack wrote:My experience of the TAB key is that, in almost all software, it behaves as you describe - i.e. moves to fixed columns rather than moving by a fixed amount. It's the way that tabs on old-fashioned typewriters worked. (Tab being short for tabulator - i.e. something designed to produce tables.)

This is exactly what you want in, for example, a text editor where you want the starts of lines to be aligned or if you are creating tables where the columns need to be aligned..
Thanks. I have mistaken its behavior for so many years. :roll:
I just test in emacs and xterm, and all behaves in same way, except in xterm( I used command 'printf"), tab key never fowards cursor to next line.

Re: tabstop vs. tabwidth

Posted: Sat Jun 09, 2018 12:21 pm
by Love4Boobies
With regards to Vim, there are things you should care about: tabstop, tabwidth and shiftwidth. Look up hard vs soft tabstops to understand the difference. For instance, I have the following line in my .vimrc:

Code: Select all

set shiftwidth=0 tabstop=4
(The zero means that shiftwidth is equal to whatever tabstop is so it's a matter of maintainability.)