Sublime Text configured as C + + IDE

Source: Internet
Author: User
Tags sublime text



In Windows, configure sublime text as the IDE for C + +.
First, in order to run C + + you need to install the g++ compiler, g++ can be found directly in Codeblocks.
Codeblock's official website is HTTP://WWW.CODEBLOCKS.ORG/DOWNLOADS/26.
You can download a more complete codeblock for programming, the address is http://sourceforge.net/projects/codeblocks/files/Binaries/16.01/Windows/ Codeblocks-16.01mingw_fortran-setup.exe.
But you can also directly mingw, and then go to their environment to find g++ compiler program.



After installing Codeblocks, you can find the Mingw\bin folder in the installation directory.









The new build system is then found in the build system in tools in sublime text.






Edit in the newly opened file (named Cplusplus.sublime-build):


{
	"path": "D:/Program Files (x86)/CodeBlocks/MinGW/bin",
	"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++",

	"variants":
	[
		{
			"name": "Run",
			"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\" < input.txt > output.txt"
		}
	]
}


The name is Cplusplus.sublime-build saved in the user directory.



Here to explain the meaning of some of the above fields, the file is actually a JSON file.



The following build system variables are included in the *.sublime-build*.


$file_path The path where the current file is located, such as C:\Files.
$file The full path to the current file, such as C:\Files\Chapter1.txt.
$file_name The file name of the current file, such as Chapter1.txt.
$file_extension The extension of the current file, such as txt.
$file_base_name The current file contains only the part of the filename, such as document.
$packages The full path to the Packages folder.
$project The full path to the current project file.
$project_path The path to the current project file.
$project_name The name of the current project file.
$project_extension The extended portion of the current project file.
$project_base_name The current project includes only the part of the name.


More introduction can be seen: http://sublimetext.info/docs/en/reference/build_systems.html



You can then see Cplusplus in the build system in tools in sublime text,






Write the Test.cpp test program, and in the same directory, create two files: Input.txt and output.txt.






After entering the input data in Input.txt, use the shortcut key ctrl+shift+b (or select Build with ... under tools). ) You can see






Choosing the first one is just compiling test.cpp, choosing the second one to compile and run the program and see the results in Output.txt.






Isn't it very convenient??



Sublime Text configured as C + + IDE


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.