1. 简介
1) ST3虽然不像notepad++可以在sidebar上显示函数列表,但是可通过Ctrl+R查看2) Ctrl+Shift+T可以打开之前关闭的tab页,这点同chrome是一样的
3) ST3使用Ctrl+P搜索文件时,使用的是模糊匹配,不像SI必须顺次拼写正确才行
4) 跳转至Caller的插件的功能还是依靠cscope
2. 安装
1) $ sudo add-apt-repository ppa:webupd8team/sublime-text-3 #添加sublime text 3的仓库2) $ sudo apt-get update #更新软件库
3) $ sudo apt-get install sublime-text-installer #安装Sublime Text 3
4) $ sudo apt-get install exuberant-ctags # 安装ctags
5) $ sudo apt-get install cscope # 安装cscope
3. 使用
1) $subl #启动
2) Sublime Text3安装Package Control的超简单方法, 在View -> Show Console中执行:
import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf),'wb').write(urllib.request.urlopen('http://sublime.wbond.net/' + pf.replace(' ','%20')).read())
3) Preferences(设置)菜单中打开Package Control(插件管理器)->Install Packages,查找并安装ctags和cscope
4) cscope -Rbkq #生成cscope.out, 建立cscope使用的索引文件
在你需要浏览源码的根目录下(如你想用cscope看linux源码)使用下面命令:
* #: cscope -Rbkq<回车>
1. R 表示把所有子目录里的文件也建立索引
2. b 表示cscope不启动自带的用户界面,而仅仅建立符号数据库
3. q生成cscope.in.out和cscope.po.out文件,加快cscope的索引速度
4. k在生成索引文件时,不搜索/usr/include目录
5) Sublime 把 tab 转成 4 个空格:
1> set tab to four spaces
Preferences -> Settings-User
{
"tab_size":4,
"translate_tabs_to_spaces": true,
"draw_white_space": "all",
"trim_trailing_white_space_on_save": true
}
再敲 tab 的时候就自动换成空格了
2> replace tab with four spaces
如果想把已经写入当前文件的 tab 都转成空格
Ctrl +` 呼出 Console
>>> view.run_command('expand_tabs')
6) CTags Key配置 (Preferences->Package Setting->CTags->Key Bindings-> User)
[
{
"command": "navigate_to_definition",
"keys": ["alt+="]
},
{
"command": "jump_back",
"keys": ["alt+,"]
},
]
7) CTags Setting
设置"command": "/usr/bin/ctags",
8) CScope配置
{
// All options in here can also be specified in your user settings
// with the prefix "CscopeSublime_".
// For example if you have
//
// {
// "CscopeSublime_display_outline": false
// }
//
// in your user settings, this will override the settings specified
// in this file.
// Whether or not to draw an outline around the matched symbol in the lookup results
"display_outline": true,
// Whether to prompt the user to edit/confirm the symbol before searching
"prompt_before_searching": false,
// The "cscope" program executable name. If needed, you can change this
// in your user settings to be the full path to the cscope executable.
// If you leave this as the default (just "cscope"), then your system
// $PATH (or %PATH% for Windows users) will be searched.
//
// Linux and OS X example: "executable": "/usr/bin/cscope"
// Windows example: "executable": "C:\\cscope\\cscope.exe"
"executable": "/usr/bin/cscope"
// A location for the cscope database - this will be used in preference to any 'found' database
//"database_location": "D:\\Program Files\\cscope\\cscope.out"
//"database_location": "/home/fw/work/blob/cscope.out"
}