Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build systems in Sublime Text

Tags:

I'm just beginning to learn programming (on C++ and Python), and by beginning I mean total beginning ("hello world" beginning...). Not wanting to use multiple IDE's, I would like to be able to code and build–simple–programs with my text editor, Sublime Text 2. Could someone indicate me, with a step-by-step tutorial, how to implement C++ and Python compiling and executing capabilities in Sublime Text.

I've searched Sublime Text build systems on the site, but the answers are very specific and can't help a rookie like me (but they'll probably help me later).

Thanks

like image 572
guillaume8375 Avatar asked Jul 30 '12 20:07

guillaume8375


People also ask

What is build system in Sublime Text?

Sublime Text provides build systems to allow users to run external programs. Examples of common uses for build systems include: compiling, transpiling, linting, and executing tests. New Build System… menu item or the Build: New Build System command palette entry.

How do I create a build system in Sublime Text 3?

Sublime Text is able to run build programs such as 'make', either when a key in pressed (F7 by default), or when a file is saved. The build system to use can be select from the Tools/Build System menu. If a project is open, the selected build system will be remembered for the project.

Where Are Sublime Text build systems stored?

sublime-build” files stored in the Sublime “Packages” directory. Should one need to locate this, it can be found in “~/Library/Application Support/Sublime Text 2/Packages/User” (if using OS X) or the corresponding Packages/User directory on other platforms.

How do I set build commands in Sublime Text?

sublime-build , and it will now be accessible in the build system menu. Select it, hit Ctrl B to build, and then hit Ctrl Shift B to run the resulting program. Or you can use a Build and Run option and call it by hitting Ctrl B , then selecting that option.


2 Answers

Sublime Text 2 already comes with scripts for building and running Python and C++ programs.

Simply press Cmd+B (or Ctrl+B on Windows & Linux) when a .py or .cpp file is open. The Python file will automatically execute and show the result in the built in console.

For C++, you need to press Cmd+Shift+B (Ctrl+Shift+B on Windows & Linux) to run it after building.

You need to have Python installed (get it here for Windows), and also a C++ compiler. The build system for C++ tries to call g++ by default (get it here for Windows. Remember to select the C++ compiler when installing!).

You will need to add the directories to path (c:\python32\ or similar for python, c:\mingw\bin or similar for the C++ compiler).

On windows, you may experience problems running the C++ programs (it tries to use bash). But Ctrl+B builds the program, and you can then use a command line to run it. Python works flawlessly on Windows.

like image 62
DkM Avatar answered Oct 03 '22 17:10

DkM


windows(install minigw, python2.7 and added to the system path)
cpp:

  1. build: ctrl+b
  2. run: ctrl+shift+b

python:

  1. build and run: ctrl+b

you may try to learn the the .sublime-build files in your Tools -> Build system -> New build system

like image 32
hustljian Avatar answered Oct 03 '22 16:10

hustljian