" run python scripts
map
" run php scripts
map
" run ruby scripts
map
" run perl scripts
map
" run make in the current directory
map
By adding these lines to your .vimrc you can easily run the current script, see the output, and then with any keystroke return to the exact spoy where you where typing.
I write the file file first in the map but you don't have to. Remember that if you don't and you don't write out your changes yourself the script won't do anything any differently than it did before.
If you want command line arguments all you have to do is add them at the vim command prompt. Let's say you run a python script and are adding command line switches and arguments to it. You press F2 and it runs your script without any arguments. Then you add argument code and want to see the effect. So in command mode you press ":" (colon) and then up arrow to get the last command that will be:
:w\|!python %
All you do is add your arguments to the end of this line as in:
:w\|!python % --XYZ-X=/foo/bar -d --quiet
python will run your scripts just as though you were on the command line.
There are other ways of doing this, but I've found this one to be the most useful. When you get into combining makefiles with shell scripts wrapped around interpreter commands it can be much more powerful.
All the best.
Comments
0 comments to "Another nice vim trick for multi language folks"
Post a Comment