www.ShoppingPodder.com

Leading Computer Shopping,
News and information


Part of the Identityscape.com network...

getxfactor.com jmoodmusic.com smartbusinesschoices.com mintdepot.com lowfaresalways.com evangelicalview.com shoppingpodder.com soproudlywehail.com webnews.ws currenthumor.com

 

 

How to set the TAB key to move 4 chars instead of 8
   Shopping Podder - the Best of Computer Postings! Forum Index -> Computer - Editors  
View previous topic :: View next topic  
Author Message
Alex Snast
Guest






PostPosted: Tue Oct 14, 2008 8:15 am    Post subject: How to set the TAB key to move 4 chars instead of 8 Reply with quote

Hello, As the topic says and i don't mean insert spaces instead

Thanks, Alex
Back to top
Stephane Chazelas
Guest






PostPosted: Tue Oct 14, 2008 8:15 am    Post subject: Re: How to set the TAB key to move 4 chars instead of 8 Reply with quote

2008-10-14, 01:23(-07), Alex Snast:
Quote:
Hello, As the topic says and i don't mean insert spaces instead
[...]


Depends on the editor. On vi, it's the ts (tabstop) option:
:set ts=4

On some terminals, you can change the tab stops of a terminal
via some escape sequences. See the "tabs" command form the GNU
termutils for instance:

$ tabs -4 | od -c
0000000 \r 033 [ 3 g \r 033 H 033 H
0000020 033 H 033 H 033 H
0000040 033 H 033 H
0000060 033 H 033 H 033 H
0000100 033 H 033 H 033 H
0000120 033 H 033 H
0000140 033 H 033 H 033 H
0000160 033 H 033 H 033 H
0000200 033 H 033 H
0000220 033 H 033 H 033 H
0000240 033 H 033 H 033 H
0000260 033 H 033 H
0000300 033 H 033 H 033 H
0000320 033 H 033 H \r
0000333

--
Stéphane
Back to top
Alex Snast
Guest






PostPosted: Tue Oct 14, 2008 9:00 am    Post subject: Re: How to set the TAB key to move 4 chars instead of 8 Reply with quote

On Oct 14, 10:35 am, Stephane Chazelas
<stephane.chaze...@unicyclist.com> wrote:
Quote:
2008-10-14, 01:23(-07), Alex Snast:> Hello, As the topic says and i don't mean insert spaces instead

[...]

Depends on the editor. On vi, it's the ts (tabstop) option:
:set ts=4

On some terminals, you can change the tab stops of a terminal
via some escape sequences. See the "tabs" command form the GNU
termutils for instance:

$ tabs -4 | od -c
0000000  \r 033   [   3   g  \r 033   H                 033   H
0000020         033   H                 033   H                 033   H
0000040                 033   H                 033   H
0000060 033   H                 033   H                 033   H
0000100         033   H                 033   H                 033   H
0000120                 033   H                 033   H
0000140 033   H                 033   H                 033   H
0000160         033   H                 033   H                 033   H
0000200                 033   H                 033   H
0000220 033   H                 033   H                 033   H
0000240         033   H                 033   H                 033   H
0000260                 033   H                 033   H
0000300 033   H                 033   H                 033   H
0000320         033   H                 033   H  \r
0000333

--
Stéphane

Thanks, How to I get that to stick as my default settings (In both
Vista and Ubuntu).
Thanks again.
Back to top
Stephane CHAZELAS
Guest






PostPosted: Tue Oct 14, 2008 9:04 am    Post subject: Re: How to set the TAB key to move 4 chars instead of 8 Reply with quote

2008-10-14, 02:00(-07), Alex Snast:
[...]
Quote:
Depends on the editor. On vi, it's the ts (tabstop) option:
:set ts=4
[...]
Thanks, How to I get that to stick as my default settings (In both
Vista and Ubuntu).

Put it in your editor configuration file. For vi, put:

set ts=4

in your ~/.exrc

If you want to change the settings of the terminal for good,
it may be done in the configuration of the terminal for some
(check their manual) or you can use something like the "tabs"
command in your shell startup file.

--
Stéphane
Back to top
Alex Snast
Guest






PostPosted: Tue Oct 14, 2008 9:13 am    Post subject: Re: How to set the TAB key to move 4 chars instead of 8 Reply with quote

On Oct 14, 11:04 am, Stephane CHAZELAS <stephane_chaze...@yahoo.fr>
wrote:
Quote:
2008-10-14, 02:00(-07), Alex Snast:
[...]

Depends on the editor. On vi, it's the ts (tabstop) option:
:set ts=4
[...]
Thanks, How to I get that to stick as my default settings (In both
Vista and Ubuntu).

Put it in your editor configuration file. For vi, put:

set ts=4

in your ~/.exrc

If you want to change the settings of the terminal for good,
it may be done in the configuration of the terminal for some
(check their manual) or you can use something like the "tabs"
command in your shell startup file.

--
Stéphane

Thanks
Back to top
Thomas E. Dickey
Guest






PostPosted: Tue Oct 14, 2008 3:47 pm    Post subject: Re: How to set the TAB key to move 4 chars instead of 8 Reply with quote

Stephane Chazelas <stephane.chazelas@unicyclist.com> wrote:
Quote:
2008-10-14, 01:23(-07), Alex Snast:
Hello, As the topic says and i don't mean insert spaces instead
[...]

Depends on the editor. On vi, it's the ts (tabstop) option:
:set ts=4

....well, OP said "move", not "insert". He can do (depending on the flavor
of vi-clone), map the tab-character to a movement command, in command-mode,
or insert-mode. So I'd suggest reading the description of "map" and related
commands.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Back to top
Juhapekka Tolvanen
Guest






PostPosted: Wed Oct 15, 2008 8:00 am    Post subject: Re: How to set the TAB key to move 4 chars instead of 8 Reply with quote

Stephane Chazelas <stephane.chazelas@unicyclist.com> writes:

Quote:
2008-10-14, 01:23(-07), Alex Snast:
Hello, As the topic says and i don't mean insert spaces instead
[...]

Depends on the editor. On vi, it's the ts (tabstop) option:
:set ts=4

On some terminals, you can change the tab stops of a terminal
via some escape sequences. See the "tabs" command form the GNU
termutils for instance:

What the heck is that? In my Debian GNU/Linux tabs-command has this
path:

/opt/heirloom/5bin/tabs

I have installed heirloom Toolchest from source code. GNU Termutils has
this WWW-page:

http://www.gnu.org/software/termutils/

Oh, no! I must suggest Debian-project to package that.


--
Juhapekka "naula" Tolvanen * http colon slash slash iki dot fi slash juhtolv
"ore wo mitsumeteiru anata sama wa ossharu bakari. kesshite dakiyosete wa
kurenai ooki na anata no te. ore no tanjoubi ni wa ai wo kai ataeru. kyou wa
kumori nochi ame." Dir en grey
Back to top
Ben C
Guest






PostPosted: Wed Oct 15, 2008 8:08 am    Post subject: Re: How to set the TAB key to move 4 chars instead of 8 Reply with quote

On 2008-10-15, Tim Roberts <timr@probo.com> wrote:
Quote:
Bob Harris <nospam.News.Bob@remove.Smith-Harris.us> wrote:

HOWEVER, after years and years of working with TABs in text files,
I have found that it is much MUCH better to just eliminate the use
of the TAB character, and instead get your editor to insert the
correct number of spaces.

Amen.

Vim will do this for you using:

set expandtabs ts=4

Why spaces instead of TABs. Because when I print my work, the
printer is going to use columns of 8 when printing real TABs.
This makes my output like like crap.

YES, and because of THAT, you should probably use this instead:

set expandtabs ts=8 sw=4 ai si

Leave hard tabs as 8, so that they will print properly. Shiftwidth will
make sure the code indents as you expect.

The option is expandtab, not expandtabs.
Back to top
Tim Roberts
Guest






PostPosted: Wed Oct 15, 2008 8:08 am    Post subject: Re: How to set the TAB key to move 4 chars instead of 8 Reply with quote

Bob Harris <nospam.News.Bob@remove.Smith-Harris.us> wrote:
Quote:

HOWEVER, after years and years of working with TABs in text files,
I have found that it is much MUCH better to just eliminate the use
of the TAB character, and instead get your editor to insert the
correct number of spaces.

Amen.

Quote:
Vim will do this for you using:

set expandtabs ts=4

Why spaces instead of TABs. Because when I print my work, the
printer is going to use columns of 8 when printing real TABs.
This makes my output like like crap.

YES, and because of THAT, you should probably use this instead:

set expandtabs ts=8 sw=4 ai si

Leave hard tabs as 8, so that they will print properly. Shiftwidth will
make sure the code indents as you expect.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Back to top
Bob Harris
Guest






PostPosted: Wed Oct 15, 2008 8:08 am    Post subject: Re: How to set the TAB key to move 4 chars instead of 8 Reply with quote

In article
<8de84cb8-3e8f-4cdd-8bd4-28ca1e47c748@k16g2000hsf.googlegroups.com
Quote:
,
Alex Snast <asnast@gmail.com> wrote:


Quote:
Hello, As the topic says and i don't mean insert spaces instead

Thanks, Alex

As others have mentioned ts=4 in vi and Vim will cause the editor
to display a TAB on column of 4 boundaries.

HOWEVER, after years and years of working with TABs in text files,
I have found that it is much MUCH better to just eliminate the use
of the TAB character, and instead get your editor to insert the
correct number of spaces. Vim will do this for you using:

set expandtabs ts=4

Why spaces instead of TABs. Because when I print my work, the
printer is going to use columns of 8 when printing real TABs.
This makes my output like like crap.

When my code is edited by fellow developers, if they use a
different perferred ts setting (or just take their editor's
default), my code will look like crap to them (which will reflect
badly against me in their eyes). Worst they may modify code and
make it look pretty using their column of 8 TABs and when I get my
code back, it will look like crap to me.

If I use 'more' or 'less' on the file, it will look like crap.

Spaces will look the same regardless of whether printed, or viewed
in anyones preferred text editor/viewer.

NOTE: If you are using Vim, and you do not care about anyone else
that might view your files, and you do not intend to print your
files, etc..., then you could use Vim mode lines to lock in your
ts settings. Just put a comment within 5 lines of the beginning
or end of your file containing:

/* vim: ts=4 expandtabs */

where /* ... */ are C source comments. Use the commenting
convention that matches the kind of file you are editing.

NOTE 2: I turn use noexpandtabs when I'm editing a file that
requires tabs as separators, such as Makefiles

Bob Harris
Back to top
Juhapekka Tolvanen
Guest






PostPosted: Wed Oct 15, 2008 8:08 am    Post subject: Re: How to set the TAB key to move 4 chars instead of 8 Reply with quote

Stephane Chazelas <stephane.chazelas@unicyclist.com> writes:

Quote:
2008-10-14, 01:23(-07), Alex Snast:
Hello, As the topic says and i don't mean insert spaces instead
[...]

Depends on the editor. On vi, it's the ts (tabstop) option:
:set ts=4

On some terminals, you can change the tab stops of a terminal
via some escape sequences.

In which terminals you can do it? It seems that at least terminal types
xterm and xterm-256color do not support that.


--
Juhapekka "naula" Tolvanen * http colon slash slash iki dot fi slash juhtolv
"ore wo mitsumeteiru anata sama wa ossharu bakari. kesshite dakiyosete wa
kurenai ooki na anata no te. ore no tanjoubi ni wa ai wo kai ataeru. kyou wa
kumori nochi ame." Dir en grey
Back to top
Stephane CHAZELAS
Guest






PostPosted: Wed Oct 15, 2008 9:38 am    Post subject: Re: How to set the TAB key to move 4 chars instead of 8 Reply with quote

2008-10-15, 06:15(+03), Juhapekka Tolvanen:
[...]
Quote:
Depends on the editor. On vi, it's the ts (tabstop) option:
:set ts=4

On some terminals, you can change the tab stops of a terminal
via some escape sequences.

In which terminals you can do it? It seems that at least terminal types
xterm and xterm-256color do not support that.
[...]


Yes, xterm supports it. Such a command was in Unix V7 30 years
ago, so I suppose it's widely supported. It's the hts (set_tab)
terminfo capability, ts in termcap.

$ TERM=xterm-256color tput hts | od -c
0000000 033 H
0000002


But beware that we're talking of the
/hardware/ (terminal) tab stops. Many applications (vi, bash,
zsh) will implement them in "software", that is, for display,
will send spaces instead of tab characters. You need to
configure those applications to tell them as far appart you want
the tab stops to be.

Try it running the "cat" command for instance.

--
Stéphane
Back to top
Thomas E. Dickey
Guest






PostPosted: Wed Oct 15, 2008 5:49 pm    Post subject: Re: How to set the TAB key to move 4 chars instead of 8 Reply with quote

Juhapekka Tolvanen <SNAFU.juhtolv.POW@mia.iki.rip.fi.fubar.example.com.invalid> wrote:
Quote:

Stephane Chazelas <stephane.chazelas@unicyclist.com> writes:

2008-10-14, 01:23(-07), Alex Snast:
Hello, As the topic says and i don't mean insert spaces instead
[...]

Depends on the editor. On vi, it's the ts (tabstop) option:
:set ts=4

On some terminals, you can change the tab stops of a terminal
via some escape sequences.

In which terminals you can do it? It seems that at least terminal types
xterm and xterm-256color do not support that.

any vt100-compatible can do this; there's a test-screen in vttest whic
illustrates it.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Back to top
Display posts from previous:   
   Shopping Podder - the Best of Computer Postings! Forum Index -> Computer - Editors  
Page 1 of 1
All times are GMT

 
Jump to:  
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 vote in polls in this forum