Why does argsdo duplicates a file?

32 views
Skip to first unread message

Igor

unread,
Nov 26, 2019, 7:00:31 AM11/26/19
to vim_use
Hi,
on vim 8.1.1244 on Ubuntu I started vim with: vim -u NONE
After using it for a while I decided to open some files into argument list: args *.txt
Now I would like to split those files: argdo vs
What happens is: c.txt is displayed left most, then the same c.txt is displayed in second window,
then b.txt is displayed in its own window and at the right there is d.txt displayed in the last window.

I expected to see c.txt displayed in one single window, but it it displayed in two windows. Why?

Regards

John Little

unread,
Nov 27, 2019, 12:45:14 AM11/27/19
to vim_use
On Wednesday, November 27, 2019 at 1:00:31 AM UTC+13, Igor wrote:

Assuming the current directory has files a.txt, b.txt, c.txt

: args *.txt

: argdo vs

> What happens is: c.txt is displayed left most, then the same c.txt ...


> I expected to see c.txt displayed in one single window, but it it displayed in two windows. Why?

The argdo vs behaves like you'd entered the following sequence:

:vs
:next
:vs
:next
:vs

Each command in isolation is doing its thing correctly.  There's three splits,
resulting in four vim windows.

If what you want is as many vim windows as arguments, in order, try

:1,$-argdo vs | wincmd w
:next

Note there's lots of options affecting vim's behaviour here.  For example, if you have 'splitright' set, it's simpler:

:set spr
:1,$-argdo vs
:next

Regards, John Little

Gary Johnson

unread,
Nov 27, 2019, 3:32:36 AM11/27/19
to vim_use
Even simpler is

:vert all

Regards,
Gary

Igor

unread,
Nov 28, 2019, 1:06:56 PM11/28/19
to vim_use
Thank you John Little for detailed explanation and thanks a lot Gary Johnson for simplified solution.
Reply all
Reply to author
Forward
0 new messages