下載對應平台的sublime
sublime最新版下載, 字體樣式個人喜歡Consolas, 另附注冊碼:
—– BEGIN LICENSE —–
TwitterInc
200 User License
EA7E-890007
1D77F72E 390CDD93 4DCBA022 FAF60790
61AA12C0 A37081C5 D0316412 4584D136
94D7F7D4 95BC8C1C 527DA828 560BB037
D1EDDD8C AE7B379F 50C9D69D B35179EF
2FE898C4 8E4277A8 555CE714 E1FB0E43
D5D52613 C3D12E98 BC49967F 7652EED2
9D2D2E61 67610860 6D338B72 5CF95C69
E36B85CC 84991F19 7575D828 470A92AB
—— END LICENSE ——
Mac下配置
選擇Tools > Build System > New Build System創建一個編譯模板,名字命名為C++11

文件內容如下:
{
"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",
"cmd": ["bash", "-c", "g++ -std=c++11 '${file}' -o 'a' && open -a terminal '${file_path}/a'"]
}
]
}
配置中的open -a terminal指的是從終端打開該文件, 如果不需要,可以將其去掉。
編寫一個簡單的c++程序測試一下

Windows下配置
c++環境設置
-
在系統環境變量
Path中添加MinGW > bin所在目錄,
點擊下載MinGW

-
同樣在
Tools > Build System > New Build System新建編譯模板,保存為C++11.sublime-build
內容為:
C++.sublime-build
{
"encoding": "utf-8",
"working_dir": "$file_path",
"shell_cmd": "g++ -Wall \"$file_name\" -o \"$file_base_name\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.c++",
"variants":
[
{
"name": "Run",
"shell_cmd": "g++ -Wall \"$file\" -o \"$file_base_name\" && start cmd /c \"\"${file_path}/${file_base_name}\" & pause\""
}
]
}
oj刷題常用模版
sublime中可以添加代碼片段
創建方法:Tools (工具)> Developer > New Snippet(新片段)
1、在新建的文件中添加如下內容
<snippet>
<content>
<![CDATA[
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int inf = 0x3f3f3f3f;
#define LOCAL
int main(int argc, char * argv[])
{
#ifdef LOCAL
freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.in", "r", stdin);
//freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.out", "w", stdout);
#endif
${1:/* code */}
while (~scanf("%d", ${2:/* var */}))
{
}
return 0;
}]]>
</content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>acm</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.c++</scope>
</snippet>
2、保存為acm.sublime-snippet
3、使用方法,在你的c++文件中輸入acm關鍵字,再按下Tap鍵
效果如下

