Running code from Vim

I recently stumbled upon (no not the service) Vi Improved also known as VIM and had planned to use it as my text editor of choice… Being a noob i had no idea how to run my code, but i stumbled upon this neat set of code.

You have to enter command mode, so press Esc.

Then type the following command without the quotes:

“:set makeprg=python\ %” 

This allows you to run python code from the editor. If you were coding in ruby you would just switch out python with ruby so:

“:set makeprg=ruby\ %”

“:set makeprg=perl\ %” for perl.

To run code you save the file and then type in without quotes:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: