首页 > 其他 > 详细

sublime自定义代码段

时间:2020-06-11 16:54:20      阅读:46      评论:0      收藏:0      [点我收藏+]

( 不定期更新 ) 可能有比较常用的东西就写成代码段保存咯, 十分好用的小技巧

一方面记录一下自己地代码段, 一方面说说方法

方法 : 工具---插件开发---新建代码片段---设置---保存(后缀改为.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>

sublime自定义代码段

原文:https://www.cnblogs.com/roccoshi/p/13093461.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!