如果在windows配置过的话这次会容易很多。相关博客很多了,我这里保存一下我借鉴并成功的配置:
关于自己build的C++,文件类型为sublime-build,直接扔在它给出的user文件夹即可,不必特意指定:
{
"cmd": ["clang++", "${file}","-std=c++11", "-stdlib=libc++", "-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", "clang++ '${file}' -std=c++11 -stdlib=libc++ -o '${file_path}/${file_base_name}' && open -a Terminal.app '${file_path}/${file_base_name}'"]
}
]
}
然鹅这个在终端运行没有我原来在win10的那个配置方便,不过有command+W快捷键关闭,就这样吧……
然后据说Mac不支持bits/stdc++.h,那么就换一种偷懒的方式……依次进入tools、developer、new snippet,建一个上图的acm.sublime-snippet,我使用的是:
<snippet>
<content><![CDATA[
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <random>
#include <string>
#include <sstream>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <fstream>
#define ri readint()
#define gc getchar()
#define R(x) scanf("%d", &x)
#define W(x) printf("%d\n", x)
#define init(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define irep(i, a, b) for (int i = a; i >= b; i--)
using namespace std; typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int inf = 0x3f3f3f3f;
const ll INF = 1e18; ]]></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>
根据自己习惯进行改写。这部分内容的使用方法详见且多谢这位前辈的博客