Sublime Forum

How to run the C code like TextMate ? / with arguments?

#1

Hello !

I’ve used Sublime Text 2 for writing some scripts. This is an awesome app, but I have two questions.

  1. How to run the C code like TextMate ?

Once I wrote the C code like below, I executed build command (Command + B on Mac), but I couldn’t run this code.

#include <stdio.h>

int main(int argc, char *argv]) {

	printf("Hello, World \n");

}

Do I need to write Make file ?
I wouldn’t like to write Make file for a little script like this . I can run this C code if I use TextMate.

  1. How to run the Ruby code with arguments ?

I could run the Ruby code with Sublime Text 2.
However, I couldn’t understand how to run the Ruby code with arguments.


Please teach me how to solve these problems.

0 Likes

#2

Let’s do the first one.

Open ST2 and go to Tools / Build System / New Build System ...

A new file will open that you need to edit.

Change “make” to the path to your favourite compiler.
Add any arguments you want to pass to the compiler next.
Then add $file to tell ST2 you want to pass the path to the current file in context.
On my system here’s what I have:

{ "cmd": "/Developer/usr/bin/clang", "-Wall", "$file"] }

With that example how to do the second question (ruby arguments) should be clear as well.

0 Likes