When I open multiple files in gvim
with no options, they are assigned to buffers in the order I specify on the command line:
gvim foo.cpp foo.h bar.cpp bar.h
Doing :ls
then yields:
1 %a "foo.cpp" line 1
2 "foo.h" line 0
3 "bar.cpp" line 0
4 "bar.h" line 0
However, when I am using --servername
and --remote
to have only one instance of gvim
, the files are loaded in a different order:
gvim --servername gvim
// Later ...
gvim --servername gvim --remote foo.cpp foo.h bar.cpp bar.h
Then :ls
yields:
2 %a "foo.cpp" line 1
3 "bar.cpp line 0
4 "foo.h" line 0
5 "bar.h" line 0
(Note that buffer 1 is not missing. It's a hidden empty buffer named [No Name]
that was created by the first call to gvim
with no file arguments)
It looks like maybe the --remote
option causes the files to be grouped by extension. Is there a way to make --remote
load the files into buffers in the same order specified on the command line?
BTW, this is with stock gvim 7.4, on CentOS 6.9, with no .vimrc
or .gvimrc
, and no plugins installed.
Update:
It looks like whatever gvim
is doing here has to do with the fact that it recognizes the extensions .cpp
and .h
as special in some way. If I replace .cpp
with .cat
and .h
with .dog
, the files are loaded in the same order specified on the command line, as expected.
gvim --servername gvim
, with no file args. It creates an empty buffer (1) which it subsequently marks hidden when some files are opened. Doing:ls!
to also show hidden buffers shows buffer 1 as[No Name]
.--servername
to maintain a single instance ofgvim
.suffixes
option if you use the--remote
command line parameter. According to:help 'suffixes'
this option should only have an effect on file names with wildcards. Maybe you can file a bug report at the Vim repository, if others come to the same conclusion.