sublime配置c++环境 X 算法竞赛

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 
#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"<
#define db(x) cerr<<(#x)<<'='<<(x)<
#define db2(x,y) cerr<<(#x)<<'='<<(x)<<' '<<(#y)<<'='<<(y)<
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
    看起来比较爽?虽然感觉并没那么好用,但说不定某时用得上。
    附上链接

2020.12.25 UPD:
真香,foc针不戳,附上配置教程:
sublime配置c++环境 X 算法竞赛_第1张图片
解决保存文件后会清空test input的问题:
在foc的setting文件中加上:“tests_file_suffix”: “__tests”,

你可能感兴趣的:(瞎搞,c++,sublime,配置)