Introduction: Compile and Run C Code in TextWrangler

About: www.about.me/georgeayad

In this tutorial i'll be demonstrating how to compile and run C code right inside of TextWrangler using Xcode's GCC C compiler , I assume that you have already installed Xcode's command line tools and i'll not be explaining how to do that in this tutorial , if you haven't , check this tutorial on OS X Daily first.

Step 1: The AppleScript

i made this apple script to use Xcode's GCC C compiler to compile and run the C file being edited in TextWrangler , it saves the changes made , compiles it to an app called "output" , then runs this "output" app.

the compiled app is saved in the same location of the C file.

download this AppleScript here.

Step 2: Put the Script in TextWrangler

Open up TextWrangler , then go to "Script menu > Open Scripts Folder"

Copy the AppleScript to TextWrangler's Scripts folder.

A new item should appear in the Scripts menu called "C compile and run".

Step 3: Set a Shortcut (Optional)

Open TextWrangler's preferences.

Navigate to "Menues & Shortcuts" > "Scripts" > "C compile and run"

Click it to set a keyboard shortcut.

I've set mine to "CMD ." , choose whatever you want but make sure not to replace a previously set default shortcut.

Step 4: Enjoy Your Development

Enjoy developing your C code , and don't forget to check my other projects on my website George Gabra Jr.