To configure the compilation environment:
Enter Sublime, then click Tools->build system->new Build System
Replace directly with the following
{ "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": "Build & Run", "Shell_cmd": "X-terminal-emulator- e bash-c \" g++ ' ${file} '-O ' ${file_path}/${ File_base_name} '; ' ${file_path}/${file_base_name} '; Read-p ' \npress ENTER or type command to continue ... ' " }, { " name ":" Build only ", " Shell_cmd ":" g+ + ' ${file} '-O ' ${file_path}/${file_base_name} ' " }, {" name ":" Run only ", " Shell_cmd ":" X-terminal-emulator- e bash-c \ "' ${file_path}/${file_base_name} '; Read-p ' \npress ENTER or type command to Continu E ... ' \ ' " } ] }
Save the file, file name arbitrary
Before each use, we press CTRL+SHIFT+B to select the Compile option
Configure one-click compilation & Run shortcut keys
Click Preferences->key buildings-user
[ {"Keys": ["Ctrl+d"], "command": "Duplicate_line"}, {"Keys": ["Alt+up"], "command": "Swap_line_up"}, {" Keys ": [" Alt+down "]," command ":" Swap_line_down "}, {" Keys ": [" F9 "]," command ":" Build "," args ": {" Variant ":" Build & Amp Run "}},"
Copy code, move up, move down, compile and run with one click
Installing the Format plugin
First you need to install the package Control
Click View->show Console, and then enter
Import Urllib.request,os; PF = ' package control.sublime-package '; IPP = Sublime.installed_packages_path (); Urllib.request.install_opener (Urllib.request.build_opener (Urllib.request.ProxyHandler ())); Open (Os.path.join (IPP, PF), ' WB '). Write (Urllib.request.urlopen (' http://sublime.wbond.net/' + pf.replace (', '%20 ')) . Read ())
After successful installation, press CTRL+SHIFT+P, then enter install, select Package Control:install
Then enter Coolformat and install
Click Preferences->browse Packages, then enter Coolformat, there is a Default.sublime-keymap open can modify shortcut keys
Ubuntu/debian/deepin et Sublime Text 3 Configuring C + + Environment (one-click compile & Run, format code)