OSDev.org
https://forum.osdev.org/

tabstop vs. tabwidth
https://forum.osdev.org/viewtopic.php?f=13&t=32990
Page 1 of 1

Author:  lovelyshell [ Thu Jun 07, 2018 12:56 am ]
Post subject:  tabstop vs. tabwidth

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.

Author:  iansjack [ Thu Jun 07, 2018 1:06 am ]
Post subject:  Re: tabstop vs. tabwidth

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

Author:  lovelyshell [ Thu Jun 07, 2018 1:52 am ]
Post subject:  Re: tabstop vs. tabwidth

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.

Author:  Love4Boobies [ Sat Jun 09, 2018 12:21 pm ]
Post subject:  Re: tabstop vs. tabwidth

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:
set shiftwidth=0 tabstop=4


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

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/