对于C++程序员来说,编辑器不是必要的,直接在IDE中写代码就可以。但有时,写一些短小的代码或者写一些脚本的时候,编辑器还是比较必要的。
以前用的是NotePad++,NotePad++还是挺不错的。本人以后想朝Linux方向发展,而Sublime是跨平台的,所以就放弃NotePad++了。
现在就记录一下,Sublime的入门级基础操作:
首先是两个快捷键:
Ctrl+` : “`”是Esc下面那个,打开控件台,可以用于运行Python代码,本人对Python了解不多,但安装package control要用到控制台。
Ctrl+Shift+p :打开“万能面板”,在里面可以查找、安装、删除插件。
常用插件:
1,package control。 我们用sublime几乎都会首先安装这个插件,这个插件是管理插件的功能,先安装它,再安装其他插件就方便了。 安装方法:
点击sublime的菜单栏 view->show console ;现在打开了控制台, 这个控制台有上下两栏, 上面一栏会实时显示sublime执行了什么插件,输出执行结果, 如果你安装的某个插件不能正常运行,应该先在这里看看有没有报错。下面栏是一个输入框,可以运行python代码。我们输入下面的代码点击回车运行, 就能安装好package control了。
- import urllib2,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read())
2, sublimecodeintel 代码提示。 sublime默认的代码提示只能提示系统函数,用户自己创建的函数、类不能提示。 如果想要提示自己建立的函数。 可以安装sublimecodeintel插件。
3,Bracket Highlighter,用于匹配括号,引号和html标签。对于很长的代码很有用。安装好之后,不需要设置插件会自动生效。
// Define region highlight styles
"bracket_styles": {
// "default" and "unmatched" styles are special
// styles. If they are not defined here,
// they will be generated internally with
// internal defaults.
// "default" style defines attributes that
// will be used for any style that does not
// explicitly define that attribute. So if
// a style does not define a color, it will
// use the color from the "default" style.
"default": {
"icon": "dot",
// BH1's original default color for reference
// "color": "entity.name.class",
"color": "brackethighlighter.default",
"style": "underline"
},
// This particular style is used to highlight
// unmatched bracket pairs. It is a special
// style.
"unmatched": {
"icon": "question",
"color": "brackethighlighter.unmatched",
"style": "outline"
},
// User defined region styles
"curly": {
"icon": "curly_bracket",
"color": "brackethighlighter.curly"
// "style": "underline"
},
"round": {
"icon": "round_bracket",
"color": "brackethighlighter.round"
// "style": "underline"
},
"square": {
"icon": "square_bracket",
"color": "brackethighlighter.square"
// "style": "underline"
},
"angle": {
"icon": "angle_bracket",
"color": "brackethighlighter.angle"
// "style": "underline"
},
"tag": {
"icon": "tag",
"color": "brackethighlighter.tag",
// "style": "underline"
},
"c_define": {
"icon": "hash",
"color": "brackethighlighter.c_define"
// "style": "underline"
},
"single_quote": {
"icon": "single_quote",
"color": "brackethighlighter.quote"
// "style": "underline"
},
"double_quote": {
"icon": "double_quote",
"color": "brackethighlighter.quote"
// "style": "underline"
},
"regex": {
"icon": "star",
"color": "brackethighlighter.quote"
// "style": "underline"
}
}
把里面的underline换成highlight就可以了。
7、sideBarEnhancement,这个插件在Sublime text 2中是没有了的,不能在线直接安装,不过可以在网上找源码。sublime text 3中是有的。