Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass argument to a script in vim system() call?

Tags:

vim

system

I would like to pass current filename % as argument of the shell script in system() call :

let rev=system("~/script %")

How can I do that for real ?

like image 250
Gilles Quenot Avatar asked Oct 26 '25 08:10

Gilles Quenot


2 Answers

Try using exec:

exec 'call system("~/script " . expand("%"))'

Depending on what you want to do you might not need exec at all (like :h system() suggests):

let foo = system("~/script " . expand("%"))
like image 153
kongo2002 Avatar answered Oct 28 '25 22:10

kongo2002


Playing around with expand() (thanks kongo2002) :

let script="~/script " . expand("%")
let rev=system(script)

Works as a charm =)

like image 30
Gilles Quenot Avatar answered Oct 28 '25 21:10

Gilles Quenot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!