Weird behaviour of :tabmove and inconsistency between the actual behaviour and the document.

314 views
Skip to first unread message

itchyny

unread,
Mar 9, 2015, 11:59:23 PM3/9/15
to vim...@googlegroups.com
Hello, all.
I think that there are some problems for :tabmove. Firstly, see the document (:h :tabmove).

:tabm[ove] [N] *:tabm* *:tabmove*
:[N]tabm[ove]
Move the current tab page to after tab page N. Use zero to
make the current tab page the first one. Without N the tab
page is made the last one. >
:-tabmove " move the tab page to the left
:tabmove " move the tab page to the right
:.tabmove " as above
:+tabmove " as above
:0tabmove " move the tab page to the beginning of the tab
" list
:$tabmove " move the tab page to the end of the tab list

Let me explain some problems related to this command.

1. :tabmove
The :tabmove with no argument and with no range moves the tab page to the last place.
The help says that `Without N the tab page is made the last one` while it says
`:tabmove " move the tab page to the right `. I think that this comment is mistaken.

2. :-tabmove
Within the latest Vim, the command :-tabmove does not move the tab page. The help says
that `:-tabmove " move the tab page to the left`. Which behaviour is correct?

3. :+tabmove
Within the latest Vim, the command :+tabmove moves the current tab page to the right position
of the right tab page (doubly right position). The help says `:+tabmove " as above`, which,
I think, means that the same behaviour of `:.tabmove`. This is inconsistent with the actual behaviour.

Basically I do not think that the comments of examples in the help are correct. I also
noticed that there are no tests for `:.tabmove`, `:+tabmove`, `:-tabmove` and `:tabmove` in testdir/test62.in.
Hope it fixed.

Thanks.

h_east

unread,
Mar 10, 2015, 3:16:52 AM3/10/15
to vim...@googlegroups.com
Hello itchyny,

2015/3/10(Tue) 12:59:23 UTC+9 itchyny:
Thank for reporting!

I fixed on the behavior of the document.
Please check attached patch.

PS
test is not added..

Best regards,
Hirohito Higashi (a.k.a h_east)
N_tabmove_bugfix.patch
Message has been deleted

h_east

unread,
Mar 10, 2015, 3:59:33 AM3/10/15
to vim...@googlegroups.com
Oops, I fixed patch and test :-)

(I could not attached patch, I paste Gist.)
https://gist.github.com/h-east/ffabb0cdd589a5f9acd2

itchyny

unread,
Mar 10, 2015, 10:07:54 AM3/10/15
to vim...@googlegroups.com
Hello, h_east.
Thank you for your patch!
I checked your patch and recompiled to find that the behaviour of `:-tabmove` and
`:+tabmove` are fixed. Great work and I hope it merged.

itchyny

Bram Moolenaar

unread,
Mar 10, 2015, 5:59:12 PM3/10/15
to h_east, vim...@googlegroups.com

Hirohito Higashi wrote:

> Oops, I fixed patch and test :-)
>
> (I could not attached patch, I paste Gist.)
> https://gist.github.com/h-east/ffabb0cdd589a5f9acd2

Thanks! I wonder if ":tabmove" should work as documented or that the
documentation needs to be adjusted. Well, the documentation is already
inconsistant, it needs to be fixed anyway.

I suppose that since we have ":0tabmove" to move the tab page to the
first position, ":$tabmove" is the most logical to move to the last
position. Then ":tabmove" without argument just moves it right.

I would expect ":.tabmove" to not do anything. But that's not actually
useful. So move it to the right, just like ":tabmove"?

--
Q: How does a UNIX Guru do Sex ?
A: unzip;strip;touch;finger;mount;fsck;more;yes;umount;sleep

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

itchyny

unread,
Mar 10, 2015, 9:07:53 PM3/10/15
to vim...@googlegroups.com, h.eas...@gmail.com
Hello, Bram.

I agree with the idea that `:.tabmove` should not move the tab page. The command `:.` does
not move the line, you know. If `:.tabmove` does not move the tabpage, the commands
`:.tabmove`, `:-tabmove`, `:+tabmove` will be consistent with `:.`, `:-`, `:+`.

The command `:tabmove` moves the tab page to the last in old Vim (I mean Vim before
7.4.530). If you change the behaviour, it breaks backward compatibility. Some users may
use `:tabmove` in order to move the tab to the last.

By the way, :tabmove 0 and :0tabmove behaves the same, sometimes I mistake as :tabmove $. This command now throws invalid argument.

itchyny

h_east

unread,
Mar 11, 2015, 2:14:47 AM3/11/15
to vim...@googlegroups.com, h.eas...@gmail.com
Hello itchyny and Bram,

2015/3/11(Wed) 10:07:53 UTC+9 itchyny:
Indeed. That's right.

I consider a specification that is consistent.

$ vim -N -u NONE -p 1 2 3 4 5 -c "tabnext"

LV : Latest Vim (7.4.658) behavior

1 [2] 3 4 5 " Now tab page status. [ ] is current tab page.
(1) :tabm " 1 3 4 5 [2] Backward compatibility ? LV:OK?
(2) :.tabm " 1 [2] 3 4 5 Stay current tab page. LV:NG
(3) :.+tabm " 1 3 [2] 4 5 Move to the right one. LV:NG
(4) :.+1tabm " Same as above. LV:NG
(5) :+tabm " Same as above. LV:NG
(6) :+1tabm " Same as above. LV:NG
(7) :tabm + " Same as above. LV:NG(E474)
(8) :tabm +1 " Same as above. LV:OK
(9) :.-tabm " [1] 2 3 4 5 Move to the left one.
(10) :.-1tabm " Same as above
(11) :-tabm " Same as above. LV:NG
(12) :-1tabm " Same as above. LV:NG
(13) :tabm - " Same as above. LV:NG(E474)
(14) :tabm -1 " Same as above. LV:OK
(15) :0tabm " [2] 1 3 4 5 Move to the first. LV:OK
(16) :tabm 0 " Same as above. LV:OK
(17) :1tabm " 1 [2] 3 4 5 Move to after tab page 1. LV:NG
(18) :tabm 1 " Same as above. LV:NG
(19) :2tabm " 1 [2] 3 4 5 Move to after tab page 2. LV:NG
(20) :tabm 2 " Same as above. LV:NG
(21) :3tabm " 1 3 [2] 4 5 Move to after tab page 3. LV:NG
(22) :tabm 3 " Same as above. LV:NG
(23) :4tabm " 1 3 4 [2] 5 Move to after tab page 4. LV:NG
(24) :tabm 4 " Same as above. LV:NG
(25) :5tabm " 1 3 4 5 [2] Move to the last. LV:OK
(26) :tabm 5 " Same as above. LV:OK
(27) :6tabm " Same as above. LV:OK
(28) :tabm 6 " Same as above. LV:OK
(29) :$tabm " Same as above. LV:OK
(30) :tabm $ " Same as above or E474? LV:OK?

Note. (17)~(24)
My ideal behavior has been along the document.
:help :tabm
> Move the current tab page to after tab page N.

What about this?

Ozaki Kiichi

unread,
Mar 11, 2015, 3:21:58 AM3/11/15
to vim...@googlegroups.com
> https://gist.github.com/h-east/ffabb0cdd589a5f9acd2

I'm concerned that it makes ":+tabmove" behavior be different from ":.+1tabmove".

I understand that ":+" of ":+tabmove" is a range expression,
and ":+" means ":.+1"; i.e. (current-tab-number)+1.

I also understand "[X]tabmove" ("X" is direct tab-number or range expression) means
`move current tab to the right side of the tab identified by "X"`.

Actually;

* ":.bnext" == go next buffer,
* ":+bnext" == go 2nd next buffer, same as ":.+1bnext".
* ":.wincmd r" == go next window
* ":+wincmd r" == go 2nd next window, same as ":.+1wincmd r"

Thus it can be said that present ":[.-+]tabmove" behaviors have consistency, at least, as long as other moving operations.

Thank you.

Ozaki Kiichi

unread,
Mar 11, 2015, 5:28:28 AM3/11/15
to vim...@googlegroups.com
> * ":.bnext" == go next buffer,
> * ":+bnext" == go 2nd next buffer, same as ":.+1bnext".
> * ":.wincmd r" == go next window
> * ":+wincmd r" == go 2nd next window, same as ":.+1wincmd r"
>
> Thus it can be said that present ":[.-+]tabmove" behaviors have consistency, at least, as long as other moving operations.

I reconsidered above, it were not appropriate as analogic command of "tabmove".
I'm sorry, but I withdraw it.

h_east

unread,
Mar 11, 2015, 6:10:08 AM3/11/15
to vim...@googlegroups.com
Hello Kiichi,

2015/3/11(Wed) 18:28:28 UTC+9 Ozaki Kiichi:
Don't mind.
Probably, Count of ':tabmove' behavior is similar to ':wincmd x'.

Thanks for pointing this.

h_east

unread,
Mar 14, 2015, 1:33:03 PM3/14/15
to vim...@googlegroups.com, h.eas...@gmail.com
Hi Bram and List,

2015/3/11(Wed) 15:14:47 UTC+9 h_east:
Bram, May I write a patch in this specification?

Bram Moolenaar

unread,
Mar 14, 2015, 6:48:01 PM3/14/15
to h_east, vim...@googlegroups.com

Hirohito Higashi wrote:

> Hi Bram and List,
>
> 2015/3/11(Wed) 15:14:47 UTC+9 h_east:
> > Hello itchyny and Bram,
> >
> > 2015/3/11(Wed) 10:07:53 UTC+9 itchyny:
> > > On Wednesday, March 11, 2015 at 6:59:12 AM UTC+9, Bram Moolenaar wrote:
> > > > Hirohito Higashi wrote:
> > > >
> > > > > Oops, I fixed patch and test :-)
> > > > >
> > > > > (I could not attached patch, I paste Gist.)
> > > > > https://gist.github.com/h-east/ffabb0cdd589a5f9acd2
> > > >
> > > > Thanks! I wonder if ":tabmove" should work as documented or that the
> > > > documentation needs to be adjusted. Well, the documentation is already
> > > > inconsistant, it needs to be fixed anyway.
> > > >
> > > > I suppose that since we have ":0tabmove" to move the tab page to the
> > > > first position, ":$tabmove" is the most logical to move to the last
> > > > position. Then ":tabmove" without argument just moves it right.
> > > >
> > > > I would expect ":.tabmove" to not do anything. But that's not actually
> > > > useful. So move it to the right, just like ":tabmove"?

I haven't have time to look into all the variations. Also, I was
wondering if something changed when the command line range
implementation was changed.

Generally, I think we should keep as much as it was before as makes
sense, but change the ones that we can all agree on that are wrong.
Thus for the ones were one or another behavior would be OK, depending on
a user preference, keep what we have.


--
You know you use Vim too much when you have this alias in your
~/.bashrc file: alias :e=/bin/vim (Eljay Love-Jensen)

h_east

unread,
Mar 17, 2015, 12:03:56 PM3/17/15
to vim...@googlegroups.com, h.eas...@gmail.com
Hi Bram and itchyny and List,

2015/3/15(Sun) 7:48:01 UTC+9 Bram Moolenaar:
I attached patch. Please check this.

Specification is below.

$ vim -N -u NONE -p 1 2 3 4 5 -c "tabnext"

1 [2] 3 4 5 " Now tab page status. [ ] is current tab page.
(1) :tabm " 1 3 4 5 [2] move to last
(2) :.tabm " do nothing
(3) :.+tabm " 1 3 [2] 4 5 Move to the right
(4) :.+1tabm " as above
(5) :+tabm " as above
(6) :+1tabm " as above
(7) :tabm + " as above
(8) :tabm +1 " as above
(9) :.-tabm " [1] 2 3 4 5 Move to the left
(10) :.-1tabm " as above
(11) :-tabm " as above
(12) :-1tabm " as above
(13) :tabm - " as above
(14) :tabm -1 " as above
(15) :0tabm " [2] 1 3 4 5 Move to the first
(16) :tabm 0 " as above
(17) :1tabm " do nothing (already moved)
(18) :tabm 1 " as above
(19) :2tabm " do nothing (already moved)
(20) :tabm 2 " as above
(21) :3tabm " 1 3 [2] 4 5 Move to after tab page 3
(22) :tabm 3 " as above
(23) :4tabm " 1 3 4 [2] 5 Move to after tab page 4
(24) :tabm 4 " as above
(25) :5tabm " 1 3 4 5 [2] Move to last tab page
(26) :tabm 5 " as above
(27) :6tabm " as above
(28) :tabm 6 " as above
(29) :$tabm " as above
(30) :tabm $ " as above
tabmove_fix4.patch

Roland Eggner

unread,
Mar 17, 2015, 4:27:09 PM3/17/15
to vim...@googlegroups.com
Hi Hirohito!
I am unsure if I understand your specification correctly. Within the
ex-commands “2” always means the 2nd tab page? Whereas within the comments “2”
always means the tab page holding the buffer named “2”?

Would the result of piping the vim command line and the comments through
“tr 1-5 A-E”, and leaving the ex commands unmodified, equivalently represent
your thoughts?

> diff -r 3bd553b9e4bf runtime/doc/tabpage.txt
> --- a/runtime/doc/tabpage.txt Sat Mar 14 15:35:52 2015 +0100
> +++ b/runtime/doc/tabpage.txt Tue Mar 17 15:09:50 2015 +0900
> @@ -202,23 +202,29 @@
> Move the current tab page to after tab page N. Use zero to
> make the current tab page the first one. Without N the tab
> page is made the last one. >
> + :.tabmove " do nothing
> :-tabmove " move the tab page to the left
> - :tabmove " move the tab page to the right
> - :.tabmove " as above
> - :+tabmove " as above
> + :+tabmove " move the tab page to the right
> :0tabmove " move the tab page to the beginning of the tab
> " list
> - :$tabmove " move the tab page to the end of the tab list
> -<
> + :tabmove 0 " as above
> + :tabmove " move the tab page to the last
> + :$tabmove " as above
> + :tabmove $ " as above
>
> :tabm[ove] +[N]
> :tabm[ove] -[N]
> Move the current tab page N places to the right (with +) or to
> - the left (with -).
> + the left (with -). >
> + :tabmove - " move the tab page to the left
> + :tabmove -1 " as above
> + :tabmove + " move the tab page to the right
> + :tabmove +1 " as above
> +
>
> Note that although it is possible to move a tab behind the N-th one by using

s/although // ?

> -:Ntabmove, it is impossible to move it by N places by using :+Ntabmove. For
> -clarification what +N means in this context see |[range]|.
> +:Ntabmove. And move it by N places by using :+Ntabmove. For clarification what

2 spaces at sentence boundaries, as in the context part of the first diff hunk?

> ++N means in this context see |[range]|.
>
>
> LOOPING OVER TAB PAGES:


Must leave testing of your patch to others, sorry.

Despite having very limited time these days, I want to say many thanks for your
careful and accurate work! Exactly such maturing of the range and bulk features
introduced since 7.4.530 is required for users to really gain the additional
“power”, which these complex features add to the vim language.


--
Roland Eggner

h_east

unread,
Mar 18, 2015, 3:54:14 AM3/18/15
to vim...@googlegroups.com, ed...@systemanalysen.net
Hi Roland,

2015/3/18(Wed) 5:27:09 UTC+9 Roland Eggner:
Oops. It was typo. Correctly is here.
(9) :.-tabm " [2] 1 3 4 5 Move to the left

I represent specification description below.

$ vim -N -u NONE -p A B C D E -c "tabnext 3"


A B [C] D E " Original state of tab pages. [ ] is current tab page.

Note:
These patterns are not intended to run in order.
Each it describes the change from Original state (A B [C] D E).

(1) :tabm " A C D E [C] " move to the last
(2) :.tabm " do nothing
(3) :.+tabm " A B D [C] E " Move to the right
(4) :.+1tabm " as above
(5) :+tabm " as above
(6) :+1tabm " as above
(7) :tabm + " as above
(8) :tabm +1 " as above
(9) :.-tabm " A [C] B D E " Move to the left
(10) :.-1tabm " as above
(11) :-tabm " as above
(12) :-1tabm " as above
(13) :tabm - " as above
(14) :tabm -1 " as above
(15) :0tabm " [C] A B D E " Move to the first
(16) :tabm 0 " as above
(17) :1tabm " A [C] B D E " Move to after tab page 1
(18) :tabm 1 " as above
(19) :2tabm " do nothing (already there)
(20) :tabm 2 " as above
(21) :3tabm " do nothing (already there)
(22) :tabm 3 " as above
(23) :4tabm " A B D [C] E " Move to after tab page 4
(24) :tabm 4 " as above
(25) :5tabm " A B D E [C] " Move to last tab page. (Equal number of tab pages)
(26) :tabm 5 " as above
(27) :6tabm " as above (Greater than number of tab pages)
(28) :tabm 6 " as above
(29) :$tabm " as above (Exactly specify the last)
(30) :tabm $ " as above


Thanks for the suggestion.

Roland Eggner

unread,
Mar 19, 2015, 8:03:17 AM3/19/15
to vim...@googlegroups.com
On 2015-03-18 Wednesday at 00:54 -0700 h_east wrote:
> > (9) :.-tabm " [1] 2 3 4 5 Move to the left
> Oops. It was typo. Correctly is here.
> (9) :.-tabm " [2] 1 3 4 5 Move to the left
>
> I represent specification description below.
>
> $ vim -N -u NONE -p A B C D E -c "tabnext 3"
>
>
> A B [C] D E " Original state of tab pages. [ ] is current tab page.
>
> Note:
> These patterns are not intended to run in order.
> Each it describes the change from Original state (A B [C] D E).

Indeed, I considered the commands running in order.
Now it is clear: consider every command as the first after the vim command line
given above.

> (1) :tabm " A C D E [C] " move to the last

s/C /B / ?
I love vim and your work gives me the feeling, you do it too.
Thank you.


--
Roland Eggner

h_east

unread,
Mar 19, 2015, 8:37:35 PM3/19/15
to vim...@googlegroups.com, ed...@systemanalysen.net
Hi Roland,

2015/3/19(Thu) 21:03:17 UTC+9 Roland Eggner:
> On 2015-03-18 Wednesday at 00:54 -0700 h_east wrote:
> > > (9) :.-tabm " [1] 2 3 4 5 Move to the left
> > Oops. It was typo. Correctly is here.
> > (9) :.-tabm " [2] 1 3 4 5 Move to the left
> >
> > I represent specification description below.
> >
> > $ vim -N -u NONE -p A B C D E -c "tabnext 3"
> >
> >
> > A B [C] D E " Original state of tab pages. [ ] is current tab page.
> >
> > Note:
> > These patterns are not intended to run in order.
> > Each it describes the change from Original state (A B [C] D E).
>
> Indeed, I considered the commands running in order.
> Now it is clear: consider every command as the first after the vim command line
> given above.
>
> > (1) :tabm " A C D E [C] " move to the last
>
> s/C /B / ?

Aha! That's right.
--> " A B D E [C]
Thank you again.

Bram Moolenaar

unread,
Mar 20, 2015, 8:51:53 AM3/20/15
to h_east, vim...@googlegroups.com
Thanks! I would appreciate if a couple of people review this.

--
Q: How does a UNIX Guru pick up a girl?
A: look; grep; which; eval; nice; uname; talk; date;

h_east

unread,
Apr 2, 2015, 10:34:37 AM4/2/15
to vim...@googlegroups.com, h.eas...@gmail.com
To: Lech Lorens
To: Marcin Szamotulski
To: Vim developers

2015/3/20(Fri) 21:51:53 UTC+9 Bram Moolenaar:
Excuse me, Please check our discuss and my patch.
I want to fix this.

Thanks.

h_east

unread,
Apr 19, 2015, 11:35:38 AM4/19/15
to vim...@googlegroups.com, h.eas...@gmail.com
Hi Bram and Vim developers,

I resend the patch that was zip compression. (patch does not changed)
Because they contains the control code that is src/testdir/test62.in's diff.
Probably, Error may occurs during the patch command executed.
So please unzip tabmove_fix4.zip and execute the patch command by tabmove_fix4.patch.

PS
Please please anyone check this patch ;-)

--
tabmove_fix4.zip

itchyny

unread,
Apr 19, 2015, 11:41:57 AM4/19/15
to vim...@googlegroups.com, h.eas...@gmail.com
Hello, Bram, Higashi-san and all.

I tried Higashi-san's patch with the latest version of Vim and confirmed that
all the behaviour of the range and the arguments for the :tabmove command works
well. Bram, would you please check and include the patch to the upstream?

Thank you Higashi-san for the patch.
Reply all
Reply to author
Forward
0 new messages