OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:28 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: tabstop vs. tabwidth
PostPosted: Thu Jun 07, 2018 12:56 am 
Offline

Joined: Thu May 10, 2018 1:05 pm
Posts: 16
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.


Top
 Profile  
 
 Post subject: Re: tabstop vs. tabwidth
PostPosted: Thu Jun 07, 2018 1:06 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
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..


Top
 Profile  
 
 Post subject: Re: tabstop vs. tabwidth
PostPosted: Thu Jun 07, 2018 1:52 am 
Offline

Joined: Thu May 10, 2018 1:05 pm
Posts: 16
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.


Top
 Profile  
 
 Post subject: Re: tabstop vs. tabwidth
PostPosted: Sat Jun 09, 2018 12:21 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
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.)

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group