shiftround option

514 views
Skip to first unread message

cyboman

unread,
Nov 17, 2012, 8:44:24 AM11/17/12
to vim...@googlegroups.com
I'm reading an online book, Learning Vim the hardway, and it talks about the shiftround option. I tried it but it didn't affect anything. The effect was the same as before. I tried reading the help but it wasn't very helpful :) Has anybody used this option before? What is the advantage of it? What am I doing wrong that I don't see its effects?

Any help is appreciated.

Marcin Szamotulski

unread,
Nov 17, 2012, 11:12:00 AM11/17/12
to vim...@googlegroups.com
On 05:44 Sat 17 Nov , cyboman wrote:
> I'm reading an online book, Learning Vim the hardway, and it talks about the shiftround option. I tried it but it didn't affect anything. The effect was the same as before. I tried reading the help but it wasn't very helpful :) Has anybody used this option before? What is the advantage of it? What am I doing wrong that I don't see its effects?
>
> Any help is appreciated.
>
> --
> 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

With noshiftround the >> on the line
x
leads to
x
when the shiftround is on
x
As you can see it is one column before.

Best,
Marcin

rail shafigulin

unread,
Nov 17, 2012, 4:04:32 PM11/17/12
to vim...@googlegroups.com, Marcin Szamotulski
I'm still no quite clear. So when I set shiftround it moves the code by the length of shiftwidth-1 when I use the >> or << ?

Christian Brabandt

unread,
Nov 17, 2012, 4:16:14 PM11/17/12
to vim...@googlegroups.com
Hi rail!
(please don't top poste)

On Sa, 17 Nov 2012, rail shafigulin wrote:

> I'm still no quite clear. So when I set shiftround it moves the code by the
> length of shiftwidth-1 when I use the >> or << ?

No, if it is set, it moves it to the next multiple value of shiftwidth,
while when it is not set, it simply moves by shiftwidth chars.

Here is an example:
If your shiftwidth value is 4 and your input starts at cell 3 indenting
using >> would move the text to cell 5 if shiftround is set, while it
moves your text to cell 7 when shiftround is not set.

regards,
Christian
--
Den (inl�ndischen) Ruhm gro�er Minister, Feldherrn, F�rsten st�rzt
eine einzige Staatsumw�lzung oder Eroberung.
-- Jean Paul

rail shafigulin

unread,
Nov 17, 2012, 5:42:48 PM11/17/12
to vim...@googlegroups.com
On Sat, Nov 17, 2012 at 4:16 PM, Christian Brabandt <cbl...@256bit.org> wrote:
Hi rail!
(please don't top poste)

On Sa, 17 Nov 2012, rail shafigulin wrote:

> I'm still no quite clear. So when I set shiftround it moves the code by the
> length of shiftwidth-1 when I use the >> or << ?

No, if it is set, it moves it to the next multiple value of shiftwidth,
while when it is not set, it simply moves by shiftwidth chars.

Here is an example:
If your shiftwidth value is 4 and your input starts at cell 3 indenting
using >> would move the text to cell 5 if shiftround is set, while it
moves your text to cell 7 when shiftround is not set.

regards,
Christian
--
Den (inländischen) Ruhm großer Minister, Feldherrn, Fürsten stürzt
eine einzige Staatsumwälzung oder Eroberung.
                -- Jean Paul

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

The "next multiple value of shiftwidth" confuses me. So if shiftwidth is 8, will the next multiple be 2, 4 or 8? How about shiftwidth of 7, will the next multiple be 7 ?

Any help is appreciated.

Marcin Szamotulski

unread,
Nov 17, 2012, 5:48:59 PM11/17/12
to vim...@googlegroups.com
On 17:42 Sat 17 Nov , rail shafigulin wrote:
> On Sat, Nov 17, 2012 at 4:16 PM, Christian Brabandt <cbl...@256bit.org>wrote:
>
> > Hi rail!
> > (please don't top poste)
> >
> > On Sa, 17 Nov 2012, rail shafigulin wrote:
> >
> > > I'm still no quite clear. So when I set shiftround it moves the code by
> > the
> > > length of shiftwidth-1 when I use the >> or << ?
> >
> > No, if it is set, it moves it to the next multiple value of shiftwidth,
> > while when it is not set, it simply moves by shiftwidth chars.
> >
> > Here is an example:
> > If your shiftwidth value is 4 and your input starts at cell 3 indenting
> > using >> would move the text to cell 5 if shiftround is set, while it
> > moves your text to cell 7 when shiftround is not set.
> >
> > regards,
> > Christian
> > --
> > Den (inl锟絥dischen) Ruhm gro锟絜r Minister, Feldherrn, F锟絩sten st锟絩zt
> > eine einzige Staatsumw锟絣zung oder Eroberung.
> > -- Jean Paul
> >
> > --
> > 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
> >
>
> The "next multiple value of shiftwidth" confuses me. So if shiftwidth is 8,
> will the next multiple be 2, 4 or 8? How about shiftwidth of 7, will the
> next multiple be 7 ?
>
> Any help is appreciated.
>
> --
> 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

Indeed, if you set shift width to 7 and the first non blank character
is at column 9 then '>>' will move it to the column 14 when 'shiftround'
is set and to column 9+7=16 when it is not set. The operator << will
move it to the column 7 when 'shiftround' is set and 9-7=2 when it is
not set.

Best,
Marcin

John Beckett

unread,
Nov 17, 2012, 6:30:33 PM11/17/12
to vim...@googlegroups.com
rail shafigulin wrote:
> I'm still no quite clear. So when I set shiftround it moves
> the code by the length of shiftwidth-1 when I use the >> or << ?

The way to think of it is this:

If you have ":set noshiftround", after adjusting an indent you
may find that the indents are NOT aligned at the "standard"
positions. The standard positions are those you would get
after indenting text that originally had no indent.

If you have ":set shiftround", after adjusting an indent, the
indent will be aligned at a standard position (the indent is
rounded to a multiple of the 'shiftwidth' option).

John

rail shafigulin

unread,
Nov 17, 2012, 7:21:36 PM11/17/12
to vim...@googlegroups.com
--
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

Thanks, John. I think I'm getting it now. Marcin thanks for the help too.
Reply all
Reply to author
Forward
0 new messages