How can one set tabstops to specific values?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How can one set tabstops to specific values?

L. A. Walsh



I'd like to be able to set tabstops in various files to useful values

like in
/etc/fstab
set ts=17,17,8,24,3

With the last tabstop repeated for the width of the line...

I've seen this in other editors and even the linux-console has
this ability -- so how can I setvim  to produce tabstops for a
variably tab'ed output file?

Thanks... I DID look through the vimhelp, but couldn't find
anything related to varying the tabs.





--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: How can one set tabstops to specific values?

Tony Mechelynck
On 14/04/13 02:33, Linda W wrote:

>
>
>
> I'd like to be able to set tabstops in various files to useful values
>
> like in
> /etc/fstab
> set ts=17,17,8,24,3
>
> With the last tabstop repeated for the width of the line...
>
> I've seen this in other editors and even the linux-console has
> this ability -- so how can I setvim  to produce tabstops for a
> variably tab'ed output file?
>
> Thanks... I DID look through the vimhelp, but couldn't find
> anything related to varying the tabs.
>

Neither could I, and I used :helpgrep

IMHO using variable *hard* tabs is courting disaster, because most other
programs (including printers, and the Python interpreter) always use
fixed hard tabs every 8 columns.

For *soft* tabs (moving the cursor by adding spaces, or sometimes a
mixture of spaces and tabs, when the <Tab> key is hit at the keyboard)
it is something else, and I've seen this kind of option wished for
several times in vim_use or vim_dev. I suppose it could be added to the
todo list, but with a low priority, because I don't see it coming in any
foreseeable future, unless someone is both willing and capable of
implementing it (are you? I'm not).

For the sake of portability, I recommend keeping 'tabstop' at its
default of 8, setting 'expandtab' on, and using any values you like for
'shiftwidth' and 'softtabstop'. This way existing hard tabs will be seen
at multiples of 8, no new ones will be added, and tabbing or indenting
will happen by adding as many or as few spaces as you like. (You might
also use :retab to get rid of existing hard tabs in favour of spaces.)


Best regards,
Tony.
--
It is something to be able to paint a particular picture, or to carve a
statue, and so to make a few objects beautiful; but it is far more
glorious to carve and paint the very atmosphere and medium through
which we look, which morally we can do.  To affect the quality of the
day, that is the highest of arts.
                -- Henry David Thoreau, "Where I Live"

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: How can one set tabstops to specific values?

Marco
In reply to this post by L. A. Walsh
On 2013–04–13 Linda W wrote:

> I'd like to be able to set tabstops in various files to useful values
>
> like in
> /etc/fstab
> set ts=17,17,8,24,3

Also interesting in this context is the concept of “elastic
tabstops”, which compute the necessary values automatically.
However, vim neither supports those.

See http://thread.gmane.org/gmane.editors.vim/108354

Marco

signature.asc (501 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How can one set tabstops to specific values?

Erik Christiansen
In reply to this post by Tony Mechelynck
On 14.04.13 03:24, Tony Mechelynck wrote:
> For the sake of portability, I recommend keeping 'tabstop' at its default of
> 8, setting 'expandtab' on, and using any values you like for 'shiftwidth'
> and 'softtabstop'. This way existing hard tabs will be seen at multiples of
> 8, no new ones will be added, and tabbing or indenting will happen by adding
> as many or as few spaces as you like. (You might also use :retab to get rid
> of existing hard tabs in favour of spaces.)

Using expandtab (and :retab when importing text, authored elsewhere)
I've used tabstop=3 shiftwidth=3 scrolloff=3 without any portability or
printing problems, in the last couple of decades of software
development, and all other text hacking.

Since there are no tab characters in the resulting text, the ancient
custom of tabstop=8 (which stems from clanking iron typewriters, IIRC),
isn't in play.

Erik

--
The New York Times has referred to Australia's gun laws as a "road map" for the
US, saying that "in the 18 years before the law, Australia suffered 13 mass
shootings - but not one in the 14 years after the law took full effect."
 - http://www.abc.net.au/news/2012-12-17/us-urged-to-consider-australia-gun-laws-example/4431262

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: How can one set tabstops to specific values?

Tony Mechelynck
On 14/04/13 14:28, Erik Christiansen wrote:

> On 14.04.13 03:24, Tony Mechelynck wrote:
>> For the sake of portability, I recommend keeping 'tabstop' at its default of
>> 8, setting 'expandtab' on, and using any values you like for 'shiftwidth'
>> and 'softtabstop'. This way existing hard tabs will be seen at multiples of
>> 8, no new ones will be added, and tabbing or indenting will happen by adding
>> as many or as few spaces as you like. (You might also use :retab to get rid
>> of existing hard tabs in favour of spaces.)
>
> Using expandtab (and :retab when importing text, authored elsewhere)
> I've used tabstop=3 shiftwidth=3 scrolloff=3 without any portability or
> printing problems, in the last couple of decades of software
> development, and all other text hacking.
>
> Since there are no tab characters in the resulting text, the ancient
> custom of tabstop=8 (which stems from clanking iron typewriters, IIRC),
> isn't in play.
>
> Erik
>
With 'expandab' on, 'tabstop' still comes into play if you get (from
someone else, probably) a file containing hard tabs. In the absence of
specific info from the author of the file, you should then assume that
hard tabs are set at 8 (with :retab, «The current value of 'tabstop' is
always used to compute the width of existing tabs.»).

And, yeah, tab stops come from clanking iron typewriters (though the
ones I used, even the old used Underwood my grand-dad gave me in, oh,
1958 maybe, had movable tab stops like those Linda is asking for).
Similarly, ASCII comes from the 7-column papertape punches on some
models of clanking iron teletypewriters.


Best regards,
Tony.
--
Harrisberger's Fourth Law of the Lab:
        Experience is directly proportional to the amount of equipment
ruined.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: How can one set tabstops to specific values?

L. A. Walsh
In reply to this post by Tony Mechelynck




Tony Mechelynck wrote:
>
>
> IMHO using variable *hard* tabs is courting disaster, because most
> other programs (including printers, and the Python interpreter) always
> use fixed hard tabs every 8 columns.
----
    But my terminal uses '2' for a tabstop (linux console is
programmable for tabstops -- including
arbitrary ones...).

(here's a bash script to do it).
----
#!/bin/bash
#console_codes(4) man page...
printf -v sts "\033H"
if (($#==0)) ; then
  echo "$0: <n>" - set tab stop to N
  exit 1
fi
declare -i tab=$1;
str=""
declare -i pos=1
while ((++pos<80)) ;do
  if ((pos%tab)); then str+=" "
  else str+="$sts"
  fi
done
echo -e "\033c"
echo  "$str"


------------------------
Specifically, I have a few file like /etc/fstab that could really use
vartabs --

I'd like to separate fields with 1 tab, but that looks poopy... Thus the
request.

For programming... I usually use a TS=2 sw=2.

If people really **want** 8, they can just set ts=8 -- as I use 1 level
of TS / indent.


> For *soft* tabs (moving the cursor by adding spaces, or sometimes a
> mixture of spaces and tabs, when the <Tab> key is hit at the keyboard)
> it is something else, and I've seen this kind of option wished for
> several times in vim_use or vim_dev. I suppose it could be added to
> the todo list, but with a low priority, because I don't see it coming
> in any foreseeable future, unless someone is both willing and capable
> of implementing it (are you? I'm not).
>
> For the sake of portability, I recommend keeping 'tabstop' at its
> default of 8, setting 'expandtab' on, and using any values you like
> for 'shiftwidth' and 'softtabstop'.
====
    For portability, using softabs causes problems -- cause then I can't
use my preferred tabs w/o retab!

i.e. if I use 1 indent/lang level, I can choose my indent and others can
too.

But if spaces are intertwined, then I have to mod- the source code to
change tab-expansion....Ug!

I have my 'more' setup to do tabs=2 as well...

But tabs=8 -- can't indent much before I am across the screen.


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: How can one set tabstops to specific values?

Lech Lorens
In reply to this post by L. A. Walsh
On Sunday, April 14, 2013 2:33:48 AM UTC+2, Linda W wrote:

> I've seen this in other editors and even the linux-console has
> this ability -- so how can I setvim  to produce tabstops for a
> variably tab'ed output file?
>
> Thanks... I DID look through the vimhelp, but couldn't find
> anything related to varying the tabs.

There used to be a working implementation of variable tabstops available in the vim-extended Vim repository at repo.or.cz. If it is very important to you, you might want to try to extract the functionality (should not be hard if you know the basics of git) and try to merge it into the current Vim source.
IIRC since the time I updated the patch, the concealment feature was introduced to Vim, which might make brining variable tabstops back to life not totally trivial. Pity that the efforts of maintaining 'vts' were in vain and it did not get merged upstream.

Cheers,
Lech

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.