window10下的配置:
先本地配好c++环境,可以在cmd里g++ -v看有没有配好
- 1 设置编译运行c++快捷键
Tools -> Build System -> New Build System
{
"encoding": "utf-8",
"working_dir": "$file_path",
"shell_cmd": "g++ -Wall -std=c++14 -DLOCAL_DEFINE \"$file\" -o \"$file_base_name\" && \"${file_path}/${file_base_name}\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": ["source.cpp"],
"variants":
[
{
"name": "Run",
"shell_cmd": "\"${file_path}/${file_base_name}\""
}
]
}
Preferences -> Key Binding 更改右边的user设置
表示f9
是编译并运行,ctrl+f10
是运行
[
{ "keys": ["f9"], "command": "build" },
{ "keys": ["ctrl+f10"], "command": "build", "args": {"variant": "Run"} }
]
- 2 生成模板
Tools -> Developer -> New Snippet
保存为acm.sublime-snippet
下面用sb
就能生成模板
<snippet>
<content><![CDATA[
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) int(x.size())
#define fk cerr<<"fk"<<endl
#define db(x) cerr<<(#x)<<'='<<(x)<<endl
#define db2(x,y) cerr<<(#x)<<'='<<(x)<<' '<<(#y)<<'='<<(y)<<endl
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
//1.integer overflow (1e5 * 1e5) (2e9 + 2e9)
//2.runtime error
//3.boundary condition
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.precision(10);
cout<<fixed;
#ifdef LOCAL_DEFINE
freopen("input.txt", "r", stdin);
#endif
#ifdef LOCAL_DEFINE
cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
return 0;
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<tabTrigger>sb</tabTrigger>
<scope>source.c++</scope>
</snippet>
-
3 配色方案
把tmTheme
文件放入C:\Users\zzy81\AppData\Roaming\Sublime Text 3\Packages\User
,重启sublime,就能在Preferences -> color shceme里选自己刚加进去的配色了,个人喜欢Tomorrow的night blue和solarize的light。 -
4 FastOlympicCoding
很好用的插件,算法竞赛爱好者必备。
附上链接
附上配置教程:
解决保存文件后会清空test input的问题:
在foc的setting文件中加上:“tests_file_suffix”: “__tests”,