Sublime Forum

Compile one single C file

#1

Hi,

Since i can’t find how to compile a single C file inside the editor, i’m willing to create a plugin for that, but before doing that, i want to know if any of you guys did a hack for that ?

Thanks.

0 Likes

#2

Okay, so i didn’t actually had to write a plugin, i just needed a build system.
Here it is :

{
    "cmd": "gcc", "$file", "-o", "$file_base_name"],
    "file_regex": "^ ]*File \"(...*?)\", line ([0-9]*)",
    "working_dir": "${project_path:${folder}}",
    "selector": "source.c"
}

If you want to add it to your Sublime Text, you just need to go Tools > Build System > New Build System and paste the code in the file then save it.
To Build, just hit Ctrl+b.

Hope it’ll help some one.
Happy coding !

0 Likes

#3

Ok, so now, i need it to actually Run the built file in my terminal.
How can i do that ?

0 Likes