quarta-feira, 11 de março de 2015

Running console command from VIM

This days i was thinking about how to run a Python script currently opened on VIM. After few minutes of googling, i found this solution by grouping some nippets found at some sites.

Inside VIM, under command mode, run this lines:

:let runner="python"
:let myArgs="put your args here. If you have not args let this be an empty string"
:w|execute '!cls &&; '.runner.' "%:p" '.myArgs

One thing We must keep in mind is that execute parses the entire string. So, if You are on Windows and want run something like Mozilla Firefox, You must use:

:let runner="\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\""
:let myArgs=""
:w|execute '!cls &&; '.runner.' "%:p" '.myArgs

Nenhum comentário:

Postar um comentário