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.
tabstop vs. tabwidth
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..
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..
-
- Posts: 16
- Joined: Thu May 10, 2018 1:05 pm
Re: tabstop vs. tabwidth
Thanks. I have mistaken its behavior for so many years.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..
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.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
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:
(The zero means that shiftwidth is equal to whatever tabstop is so it's a matter of maintainability.)
Code: Select all
set shiftwidth=0 tabstop=4
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]