# Why sublime-text?
# Because, it is lightweight, portable, and runs on Win/Linux/MacOS.
# and it is really awesome.
# it is more flexible and extensible.
# You can turn your Sublime-text editor into a FULL featured IDE.
# I really use it for C/C++/HTML/JS/CSS/Python/Java, and it is great.
# Sublime-Text Editor is more real, because it allows you to customize almost everything.
# For Compiled languages, you can use pre-built BUILD SYSTEM or create your own.
# Snippet, that is a great idea and that would be great if you learn, how to write snippet and use them.
# Why we are here?
# What is Build-system in Sublime-Text Editor?
# Build-system allows you to write and build programs directly ( Just hit, CTRL+b ) and if you want to run build binary ( Just hit, SHIFT+CTRL+b )
# Build System ( RUN, BUILD ) basically allows you to run Two COMMANS using their shortcut key, that really does not matter which command you want to invoke with CTRL+b and CTRL+SHIFT+b.
# What about pre-built BUILD SYSTEM for C++
# Hmm, that is great, but we want some more functionality ( I want to pass some command line parameters ) , this is why we want to write our own Custom BUILD SYSTEM for C++.
# Sublime-Text Build System Script for C/C++
## When, You want to use Flags like, -std=c++11
#### C++11.sublime-build ( FOR LINUX )
{
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cpp",
"variants":
[
{
"name": "Run",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -std=c++11 && \"${file_path}/${file_base_name}\""
}
]
}
####
## When, you want to run your program in Terminal ( xterm ) instead of sublime-Text console, Becaue you can pass input using Sublime-Text Console.
## NOTE, that you may not be able to see terminal because your program won't wait for your response.
## So, you need to stop your C/C++ program from being exiting automatically.
#### C++11.sublime-build
{
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cpp",
"variants":
[
{
"name": "Run",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -std=c++11 && \"${file_path}/${file_base_name}\""
}
]
}
####
# When, you want to run your program in a separate terminal process, that won't exit automatically even if program exists itself or you can tell xTerm, not to close itself.
# FINAL Version : filename: C++11.sublime-build
# PATH : $USER_HOME/.config/sublime-text-3/Packages/User/
# FOR LINUX Operating System
#### C++11.sublime-build
{
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cpp",
"variants":
[
{
"name": "Run",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -std=c++11 && xterm -fg green -bg black -hold -e \"${file_path}/${file_base_name}\""
}
]
}
####
# FINAL Version : filename: C++11.sublime-build
# PATH : %sublime-text-3%\Packages\User\
# For Windows:-
# NOTE, Ensure that GNU GCC Compiler is in your System PATH environment variable.
# If you want to check whether g++/gcc BINARY is in your system PATH.
# use which Command for LINUX ( which -a g++ )
# use where Command for Windows ( where gcc )
# So if you are a Windows user and you might want to use some external Terminal Emulator Programs for Windows, just like, ( mintty, console2, cmder, conemu ) .
# I recommend you to use mintty terminal emulator for windows that works just as xterm in Linux.
# Command Example:-
mintty --hold always -e g++ sample.cpp -o sample.exe
# One, more TIP for windows user( Optional for Linux Users)
# Sometimes you might want to supply some input to your program.
# There are actually two ways, first, You are going to type each and every required value, but for sublime, let me tell you one thing, Sublime-Text-3 console is not Interactive, means it will not ask you for any input, this just runs and show you the output.
# BUT you have second option, When you want to automate your compiled program, OK, we are going to write every required query for proper functioning of our program in a separate text file and tell Sublime-Text-3 to take input data from this file Instead of STDIN FILE.
{ "shell_cmd": "g++ -std=c++11 \"${file}\" -o \"${file_path}/${file_base_name}.exe\"", "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}", "selector": "source.c, source.c++, source.cpp", "variants": [ { "name": "Run", "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -std=c++11 && mintty --hold always -e \"${file_path}/${file_base_name}.exe\"" } ] }
# Take a look :-
# Download Sublime Text Editor :-
http://www.sublimetext.com/
http://www.sublimetext.com/3
# References :-
http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/reference/build_systems.html
No comments :
Post a Comment