Home Download Buy Blog Forum Support

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

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

Postby mzu on Sun May 08, 2011 11:42 am

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.

Code: Select all
#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.


2. 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.
mzu
 
Posts: 1
Joined: Sun May 08, 2011 11:30 am

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

Postby duncan on Sat Aug 27, 2011 1:13 pm

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:
Code: Select all
{
    "cmd": ["/Developer/usr/bin/clang", "-Wall", "$file"]
}


With that example how to do the second question (ruby arguments) should be clear as well.
duncan
 
Posts: 17
Joined: Sat Aug 27, 2011 12:59 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 22 guests