Skip to content

Instantly share code, notes, and snippets.

@g0xA52A2A
Last active October 1, 2021 21:08
Show Gist options
  • Save g0xA52A2A/16e31d0caa7f3f8f173f146efb67c4a4 to your computer and use it in GitHub Desktop.
Save g0xA52A2A/16e31d0caa7f3f8f173f146efb67c4a4 to your computer and use it in GitHub Desktop.

As of 8.1.2233 Vim has v:argv available to represent the arguments Vim was invoked with as a list.

We can get an equivalent list on *NIX systems with the following, useful if the version of Vim does not support v:args.

split(system('ps -o command= -p' . getpid()))

We could use something like the following as a compatibility shim, though of course an extra condition for non *NIX systems is missing.

function! GetArgv() abort
  return exists('v:argv') ?
    \ v:argv :
    \ split(system('ps -o command= -p' . getpid()))
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment