I want to execute an external command in Vim script but I don't how can I do this. For example I need to change a file permission using chmod
command (Please assume application has enough permission to run the command)
Is there any way to achieve this?
If you want users to see the output (or interact with the command) :!
is the right command. For silent execution (as I suppose would be desired with your chmod
), using system()
is preferable. Especially on Windows, this avoids the popup of a command prompt that must be dismissed manually.
:call system('chmod +x ' . shellescape(fname))