Reputation: 41
How can I access the arguments that were given to Vim on the command line under Windows?
I'm looking for the the equivalent to argv[]
in C.
Under linux you can read /proc/self/cmdline
.
Example:
vim -c ":echo split( readfile( \"/proc/self/cmdline\", 1 )[0], \"\n\" )"
print
[
'vim',
'-c',
':echo split( readfile( "/proc/self/cmdline", 1 )[0], "\n" )'
]
argc()
and argv()
don't work. They just return number of files.
Example:
vim -c ':echo "argc:" . argc() . ", argv:" . string( argv() )' file1 file2
print
argc:2, argv:['file1', 'file2']
Upvotes: 4
Views: 1101
Reputation: 21
In the specific case of needing argv[0] (i.e., the name vim was called by), you can use v:progname
.
Upvotes: 2
Reputation: 3361
:help argc()
:help argv()
:help argidx()
And maybe also :help argument-list
, just to be sure.
Simple example:
for arg in argv()
echo arg
endfor
Upvotes: 5