( 不定期更新 ) 可能有比较常用的东西就写成代码段保存咯, 十分好用的小技巧
一方面记录一下自己地代码段, 一方面说说方法
方法 : 工具---插件开发---新建代码片段---设置---保存(后缀改为.sublime-snippet)
名称 | 功能 |
---|---|
cf | 生成一套cf模板 |
for2 | 两层for循环 |
tobit | 十进制转二进制 |
toint | 二进制转十进制 |
cf
<snippet>
<content><![CDATA[
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
return 0;
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>cf</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.c++</scope>
</snippet>
for2
<snippet>
<content><![CDATA[
for(int i = 0; i < ${1:n}; ++i) {
for(int j = 0; j < ${2:m}; ++j) {
${3:/*code*/}
}
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>for2</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.c++</scope>
</snippet>
tobit
<snippet>
<content><![CDATA[
string tobit(long long x, int m) { // 作用 : 十进制数(x)转二进制字符串(m位), 前补0
string s(m,‘\0‘);
for(int i = m-1; i >= 0; --i)
{
s[i] = (x & 1) + ‘0‘;
x >>= 1;
}
return s;
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tobit</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.c++</scope>
</snippet>
toint
<snippet>
<content><![CDATA[
long long toint(string s) { // 作用 : 二进制串转十进制数 (long long)
long long x = 0;
int m = s.size();
for (int j = 0; j < m; ++j)
{
x = x*2 + s[j] - ‘0‘; // 二进制s --> 十进制x
}
return x;
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>toint</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.c++</scope>
</snippet>
原文:https://www.cnblogs.com/roccoshi/p/13093461.html