Sublime Text 最佳化配置

來源:互聯網
上載者:User

標籤:

以前經常用Notepad++,最近因為需要長期在Linux環境下進行C開發,就使用了sublime Text 2,這裡就不介紹基本的了主要針對我使用的經驗中進行一些總結.

1.pacage control安裝

這個應該是一個必須的選項了,使用這個外掛程式可以很方便的管理其他的外掛程式.安裝很簡單:

ctr+`調出控制台然後粘貼如下python代碼:

Sublime Text 2

import urllib2,os,hashlib; h = ‘eb2297e1a458f27d836c04bb0cbaf282‘ + ‘d0e7a3098092775ccb37ca9d6b2e4b7d‘; pf = ‘Package Control.sublime-package‘; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( ‘http://packagecontrol.io/‘ + pf.replace(‘ ‘, ‘%20‘)).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), ‘wb‘ ).write(by) if dh == h else None; print(‘Error validating download (got %s instead of %s), please try manual install‘ % (dh, h) if dh != h else ‘Please restart Sublime Text to finish installation‘) 

 Sublime Text 3

import urllib.request,os,hashlib; h = ‘eb2297e1a458f27d836c04bb0cbaf282‘ + ‘d0e7a3098092775ccb37ca9d6b2e4b7d‘; pf = ‘Package Control.sublime-package‘; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( ‘http://packagecontrol.io/‘ + pf.replace(‘ ‘, ‘%20‘)).read(); dh = hashlib.sha256(by).hexdigest(); print(‘Error validating download (got %s instead of %s), please try manual install‘ % (dh, h)) if dh != h else open(os.path.join( ipp, pf), ‘wb‘ ).write(by) 

如果安裝成功則可以看到Package Control就說明安裝成功了!

 

2.中文支援

Sublime Text支援UTF-8編碼,要支援中文的話需要安裝一個外掛程式

ctr+shift+p輸入pci,然後輸入ConvertToUTF8,下載安裝就可以了.

 

3.等寬字型設定和游標

我使用的是Ubuntu,習慣使用Ubuntu Mono

Preferences->Setting-User

編輯:

["caret_style": "phase",    "font_face": "Ubuntu Mono",    "font_size": 15.0,    "highlight_line": true,    "highlight_modified_tabs": true]

"caret_style": "phase":柔化游標

"font_face": "Ubuntu Mono":設定字型

"highlight_line": true:高亮選中行

"highlight_modified_tabs": 高亮編輯中的檔案選項卡

 

4.設定主題

當顯示檔案分類樹(ctr+k,ctr+b)的時候左邊預設是白色的,感覺很不協調.我選用了另一個不錯的主題Theme-Flatland:

這個主題可以用包管理器下載安裝

圖2 預設的分類樹主題

圖3 Theme-Flatland主題

然後配置一下就ok

       "theme": "Flatland Dark.sublime-theme",        "color_scheme": "Packages/Theme - Flatland/Flatland Monokai.tmTheme",        "flatland_sidebar_tree_small" : true,
5.中文IME

這個是很嚴重的,再ubutu下使用搜狗IME是無法輸入中文的,需要自己編譯共用庫。

我的sublime 安裝目錄在/opt/sublime_text_2

首先需要下載gtk的lib檔案

sudo apt-get install libgtk2.0-dev

然後編輯檔案:sublime_imfix.c

#include <gtk/gtkimcontext.h>void gtk_im_context_set_client_window (GtkIMContext *context, GdkWindow    *window){    GtkIMContextClass *klass;    g_return_if_fail (GTK_IS_IM_CONTEXT (context));    klass = GTK_IM_CONTEXT_GET_CLASS (context);    if (klass->set_client_window)        klass->set_client_window (context, window);    g_object_set_data(G_OBJECT(context),"window",window);    if(!GDK_IS_WINDOW (window))        return;    int width = gdk_window_get_width(window);    int height = gdk_window_get_height(window);    if(width != 0 && height !=0)        gtk_im_context_focus_in(context);}

然後編譯

gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk+-2.0` -fPIC

成功的話就會出現libsublime-imfix.so檔案

然後將這個檔案移動到sublime安裝目錄下,我的在/opt/sublime_text_2

sudo mv libsublime-imfix.so /opt/sublime_text_2/

編輯/usr/bin/subl檔案,這是一個shell指令碼

內容如下,個別地方按照自己的情況編寫:

#!/bin/bashLD_PRELOAD=/opt/sublime_text_2/libsublime-imfix.so exec /opt/sublime_text_2/sublime_text "[email protected]"

然後執行指令碼 subl

現在就可以再sublime裡面輸入中文了。  

 本文參考了:1.https://packagecontrol.io/installation#st3   包管理器官網

  2. http://www.linuxeden.com/html/softuse/20130726/141753.html 一份不錯的操作教程

  3. http://jingyan.baidu.com/article/f3ad7d0ff8731609c3345b3b.html 解決中文IME問題

  4.http://www.cnblogs.com/figure9/p/sublime-text-complete-guide.html#3164492 一份不錯的操作教程

 

Sublime Text 最佳化配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.