[tabnext/tabprevious] {count} inconsistency

65 views
Skip to first unread message

Christian Brabandt

unread,
Jan 22, 2016, 6:05:13 AM1/22/16
to vim...@vim.org
Hi,
I think, there is an inconsistency with regard to the :tabnext and
:tabprev commands:


:tabn[ext] {count}
{count}<C-PageDown>
{count}gt Go to tab page {count}. The first tab page has number one.

:tabp[revious] {count}
:tabN[ext] {count}
{count}<C-PageUp>
{count}gT Go {count} tab pages back. Wraps around from the first one
to the last one.

Note, the first does go to the specified number, while the second goes
that many numbers back.

Could we adjust this, so that perhaps :tabn +{count} always goes {count}
number forwards and :tab {count} moves to the specified tabnumber
and :tabprevious +{count} moves that many number backwards, while
:tabprevious {count} goes to the specified number? (and perhapse
-{count} goes into the opposite direction?)

This is slightly backwards compatible, so perhaps there are other
opinions?

Best,
Christian
--
Unkraut nennt man die Pflanzen, deren Vorzüge noch nicht erkannt
worden sind.
-- Ralph Waldo Emerson

Tony Mechelynck

unread,
Jan 22, 2016, 6:43:13 AM1/22/16
to vim_dev, vim...@vim.org
On Fri, Jan 22, 2016 at 12:04 PM, Christian Brabandt <cbl...@256bit.org> wrote:
> Hi,
> I think, there is an inconsistency with regard to the :tabnext and
> :tabprev commands:
>
>
> :tabn[ext] {count}
> {count}<C-PageDown>
> {count}gt Go to tab page {count}. The first tab page has number one.
>
> :tabp[revious] {count}
> :tabN[ext] {count}
> {count}<C-PageUp>
> {count}gT Go {count} tab pages back. Wraps around from the first one
> to the last one.
>
> Note, the first does go to the specified number, while the second goes
> that many numbers back.
>
> Could we adjust this, so that perhaps :tabn +{count} always goes {count}
> number forwards and :tab {count} moves to the specified tabnumber
> and :tabprevious +{count} moves that many number backwards, while
> :tabprevious {count} goes to the specified number? (and perhapse
> -{count} goes into the opposite direction?)
>
> This is slightly backwards compatible, so perhaps there are other
> opinions?
>
> Best,
> Christian

I don't know the history of how these commands came into being, but I
can imagine that the "forward" case was done by analogy with Ctrl-W w
(without a count: go to next window round-robin; with a count: go to
window n, top-left is 1) and that in the "back" case, Bram wanted to
avoid the synonymity that we have in the case of Ctrl-W W (without a
count: go to previous window round-robin; with a count: go to window
n, top-left is 1).

I don't use tab pages, but I do use Ctrl-W w with a count to get to
the nth window. I think that the change you propose would be more than
"slightly" backwards-incompatible. The present situation is asymmetric
in the case of tabs, symmetric in the case of windows; neither is
really elegant, but I think both are usable.

Best regards,
Tony.

Tony Mechelynck

unread,
Jan 22, 2016, 6:50:52 AM1/22/16
to vim_dev, vim...@vim.org
P.S. I can't remember a command taking a three-way signed count (with
+ - or neither), or even just a signed count (with - or nothing). Is
it possible without a major overhaul of the Vim code?

Best regards,
Tony.

Christian Brabandt

unread,
Jan 22, 2016, 7:15:01 AM1/22/16
to vim_dev, vim...@vim.org
Hi Tony!

On Fr, 22 Jan 2016, Tony Mechelynck wrote:

> On Fri, Jan 22, 2016 at 12:43 PM, Tony Mechelynck
> <antoine.m...@gmail.com> wrote:
> > On Fri, Jan 22, 2016 at 12:04 PM, Christian Brabandt <cbl...@256bit.org> wrote:
> >> Hi,
> >> I think, there is an inconsistency with regard to the :tabnext and
> >> :tabprev commands:
> >>
> >>
> >> :tabn[ext] {count}
> >> {count}<C-PageDown>
> >> {count}gt Go to tab page {count}. The first tab page has number one.
> >>
> >> :tabp[revious] {count}
> >> :tabN[ext] {count}
> >> {count}<C-PageUp>
> >> {count}gT Go {count} tab pages back. Wraps around from the first one
> >> to the last one.
> >>
> >> Note, the first does go to the specified number, while the second goes
> >> that many numbers back.
> >>
> >> Could we adjust this, so that perhaps :tabn +{count} always goes {count}
> >> number forwards and :tab {count} moves to the specified tabnumber
> >> and :tabprevious +{count} moves that many number backwards, while
> >> :tabprevious {count} goes to the specified number? (and perhapse
> >> -{count} goes into the opposite direction?)
> >>
> >> This is slightly backwards compatible, so perhaps there are other
> >> opinions?

I meant incompatible

> > I don't know the history of how these commands came into being, but I
> > can imagine that the "forward" case was done by analogy with Ctrl-W w
> > (without a count: go to next window round-robin; with a count: go to
> > window n, top-left is 1) and that in the "back" case, Bram wanted to
> > avoid the synonymity that we have in the case of Ctrl-W W (without a
> > count: go to previous window round-robin; with a count: go to window
> > n, top-left is 1).
> >
> > I don't use tab pages, but I do use Ctrl-W w with a count to get to
> > the nth window. I think that the change you propose would be more than
> > "slightly" backwards-incompatible. The present situation is asymmetric
> > in the case of tabs, symmetric in the case of windows; neither is
> > really elegant, but I think both are usable.
>
> P.S. I can't remember a command taking a three-way signed count (with
> + - or neither), or even just a signed count (with - or nothing). Is
> it possible without a major overhaul of the Vim code?

:h :tabmove
(and I thought I saw it somewhere else).

Best,
Christian
--
Bescheidenheit ist eine Eigenschaft, für die der Mensch bewundert
wird, falls die Leute je von ihm hören sollten.
-- Edgar Watson Howe

Christian Brabandt

unread,
Jan 22, 2016, 7:19:08 AM1/22/16
to vim_dev, vim...@vim.org
Hi Tony!

On Fr, 22 Jan 2016, Tony Mechelynck wrote:

It is only backwards incompatible for :tabprevious and I think current
behaviour is confusing at best.

I was just trying to add a :tabnext :tabprevious command to a plugin and
I had to read the help several times, before I noticed the difference
and the tabnext command was a lot more complicated that at first
thought.

Best,
Christian
--
Das größte Problem beim Fußball sind die Spieler.
Wenn wir die abschaffen könnten, wäre alles gut.
-- Helmut Schulte

Bram Moolenaar

unread,
Jan 23, 2016, 2:33:33 PM1/23/16
to Christian Brabandt, vim...@vim.org

Christian Brabandt wrote:

>
> I think, there is an inconsistency with regard to the :tabnext and
> :tabprev commands:
>
>
> :tabn[ext] {count}
> {count}<C-PageDown>
> {count}gt Go to tab page {count}. The first tab page has number one.
>
> :tabp[revious] {count}
> :tabN[ext] {count}
> {count}<C-PageUp>
> {count}gT Go {count} tab pages back. Wraps around from the first one
> to the last one.
>
> Note, the first does go to the specified number, while the second goes
> that many numbers back.
>
> Could we adjust this, so that perhaps :tabn +{count} always goes {count}
> number forwards and :tab {count} moves to the specified tabnumber
> and :tabprevious +{count} moves that many number backwards, while
> :tabprevious {count} goes to the specified number? (and perhapse
> -{count} goes into the opposite direction?)
>
> This is slightly backwards compatible, so perhaps there are other
> opinions?

I think we need to keep the current behavior. Changing it might break a
plugin and upset those who are used to the current behavior.
I do think that "2gt" should have meant "go two tab pages forward", but
now that it already means "go to the second tab page", and people are
likely using that, we can't change it.

So we need a command to go two tabpages forward. For the Ex command we
could use ":tabforward 2".

But it's more useful to have a neighbor to "gt". There is no obvious
one...

--
If Pacman had affected us as kids we'd be running around in dark rooms,
munching pills and listening to repetitive music.
-- Marcus Brigstocke

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christian Brabandt

unread,
Jan 23, 2016, 2:49:54 PM1/23/16
to vim...@vim.org
Hi Bram!
gl?

Best,
Christian
--
Stilblüten aus Polizeiberichten und Gerichtsverhandlungen:
Die alarmierte Feuerwehr hat an Ort und Stelle festgestellt, daß es
bei dem Feuer, daß bei einer Temperatur von 18 Grad C° verlief, zur
vollkommenen Verbrennung des Schobers kam.

Bram Moolenaar

unread,
Jan 23, 2016, 4:16:42 PM1/23/16
to Christian Brabandt, vim...@vim.org
Considering that gk and gj are variants on k and j, I would expect gl
and gh to be used as variants of l and h.

--
How To Keep A Healthy Level Of Insanity:
12. Sing along at the opera.
Reply all
Reply to author
Forward
0 new messages