安裝sublime 3
- sudo add-apt-repository ppa:webupd8team/sublime-text-3
- sudo apt-get update
- sudo apt-get install sublime-text-installer
package control安裝
ctrl + `(1旁邊的波浪線)
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())
插件安裝
插件安裝方法: ctrl + shift + p
sublime具體插件: https://packagecontrol.io/search
插件名稱 | 簡介 |
---|---|
Emmet | 前端開發神器 |
sublimeLinter | 代碼檢測工具 |
SideBarEnhancements | 側邊欄 |
SyncedSideBar | 實時更新側邊欄的內容 |
BracketHighlighter | 高亮 |
SublimeCodeIntel | 代碼自動補全 |
Alignment | 代碼自動對齊 |
DocBlockr | 代碼自動注釋 |
ConvertToUTF8 | 解決中文亂碼問題 |
All AutoComplete | 讓代碼自動完成的匹配從所有打開的文件里去匹配 |
C++11 | 添加c++11語法支持 |
C++ Completes | c++語法支持 |
C++ Snippets | c++相關代碼片段 |
C++ NamespaceTool | 自動添加命名空間 |
C++YouCompleteMe | c++語法 |
Markdown Preview | mkd預覽 |
MarkdownEditing | mkd編輯 |
ubuntu配置SublimeClang
cd ~./config/sublime-text-3/Packages
git clone --recursive https://github.com/quarnster/SublimeClang SublimeClang
cd SublimeClang
git pull && git submodule foreach --recursive git pull origin master
// 拷貝libclang.so到internals文件夾
sudo apt-get install libclang-3.5
ldconfig -p | grep clang
cp /usr/lib/i386-linux-gnu/libclang-3.5.so ~/.config/sublime-text-3/Packages/SublimeClang/internals/libclang.so
// 手動編譯出libcache.so
cd src
mkdir build
cd build
cmake ..
make
重啟sublime即可
配置sublimeClang: perference -> package setting ->sublimeClang ->setting user
{
"show_output_panel": false,
"dont_prepend_clang_includes": false,
"inhibit_sublime_completions": false,
"options":
[
"-std=c++11",
"-isystem", "/usr/include",
"-isystem", "/usr/include/c++/*",
"-isystem", "/usr/include/c++/4.8",
"-isystem", "/usr/include/c++/4.8/*",
"-isystem", "/usr/include/boost",
"-isystem", "/usr/include/boost/**",
"-isystem", "/usr/lib/gcc/x86_64-linux-gnu/4.8/include",
"-isystem", "/usr/lib/gcc/x86_64-linux-gnu/4.8/include/*"
]
}
根據自己的實際的庫安裝的位置進行配置
Cscope配置(代碼調用查看)
- sudo apt-get install cscope
- perference -> package control -> install package -> cscope
- perference -> package settings -> CscopeSublime ->setting user
- 右鍵點擊工程->選擇Cscope: rebuild database
我的配置
{
// 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": true,
// 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": "cscope",
// A location for the cscope database - this will be used in preference to any 'found' database
"database_location": "/home/hhf/workspace/cscope.out"
}
Ctags
- 下載ctags: http://ctags.sourceforge.net/
- perference -> package control -> install package -> ctags
-
- 右鍵點擊工程->選擇ctags: rebuild tags
導入工程
- Project -> Add Floder to Project -> 選擇你的工程
- Project -> Save project as -> 找個地方存你的工程文件
- Edit Project 寫入自己的配置文件
我的配置
{
"folders":
[
{
"follow_symlinks": true,
"path": "/home/hhf/workspace/firmware/main"
}
],
"settings":
{
"sublimeclang_options":
[
"-I/home/hhf/workspace/firmware/main",
"-I/home/hhf/workspace/firmware/main/include",
"-I/home/hhf/workspace/firmware/main/json",
"-I/home/hhf/workspace/firmware/main/main",
"-I/home/hhf/workspace/firmware/main/util",
"-I/home/hhf/workspace/firmware/main/speech",
"-I/home/hhf/workspace/firmware/main/main/Skills",
]
}
}
這個要根據自己工程的實際路徑進行配置, 不然就找不到相關的頭文件路徑
適配eclipse的快捷鍵
[
/**
* 適配eclipse快捷鍵
*
* 下面這位仁兄早就有了這個想法
* Eclipse shortcuts for Sublime Text 2
* http://icoloma.blogspot.com/2011/10/eclipse-shortcuts-for-sublime-text-2.html
*/
{ "keys": ["alt+."], "command": "auto_complete" },
{ "keys": ["ctrl+i"], "command": "reindent" },
// 當前行和下面一行交互位置
{ "keys": ["alt+up"], "command": "swap_line_up" },
{ "keys": ["alt+down"], "command": "swap_line_down" },
// 刪除整行
{ "keys": ["ctrl+d"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
// 光標移動到指定行
{ "keys": ["ctrl+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
// 快速定位到選中的文字
{ "keys": ["ctrl+k"], "command": "find_under_expand_skip" },
// { "keys": ["ctrl+shift+x"], "command": "swap_case" },
{ "keys": ["ctrl+shift+x"], "command": "upper_case" },
{ "keys": ["ctrl+shift+y"], "command": "lower_case" },
// 在當前行的下一行插入空行(這時鼠標可以在當前行的任一位置, 不一定是最后)
{ "keys": ["shift+enter"], "command": "run_macro_file", "args": {"file": "Packages/Default/Add Line.sublime-macro"} },
// 當前文件中的關鍵字(方便快速查找內容)
{ "keys": ["ctrl+alt+o"], "command": "show_overlay", "args": {"overlay": "goto", "text": "#"} },
// 文件內查找/替換
{ "keys": ["ctrl+f"], "command": "show_panel", "args": {"panel": "replace"} },
// 全局查找/替換, 在查詢結果中雙擊跳轉到匹配位置
{"keys": ["ctrl+h"], "command": "show_panel", "args": {"panel": "find_in_files"} },
]
sublime 本身的一些快捷鍵
快捷鍵 | 作用 |
---|---|
ctrl + p | 快速打開文件 |
ctrl + r | 本文件中函數列表 |
ctrl + shift + p | 快速打開安裝包 |