# 建个目录 mkdir -p /opt/Backup cd /opt/Backup # 下载相应的tarball: http://www.sublimetext.com/3 wget http://[st3.tar.bz2] tar jxvf [st3.tar.bz2] mv sublime_text_3 /opt/sublime_text # 放到/opt下 # 创建软连接,以方便终端打开 ln -s /opt/sublime_text/sublime_text /usr/bin/sublime # 创建桌面快捷 cp /opt/sublime_text/sublime_text.desktop /usr/share/applications cd /usr/share/applications vi sublime_text.desktop # 更改"Icon=/opt/sublime_text/Icon/48x48/sublime-text.png" # 而后,于"Applications > Programming > Sublime Text"右键"Add this launcher to desktop"
ps: 一开始没注意,下载的是deb包。须要安装alien将deb转为rpm再安装。(可忽略,直接跳到第2节)python
# 安装alien: http://ftp.de.debian.org/debian/pool/main/a/alien/ wget http://ftp.de.debian.org/debian/pool/main/a/alien/alien_8.90.tar.gz tar zxvf alien_8.90.tar.gz cd alien perl Makefile.PL # 可能会遇到"Issue 1" make make install # deb转为rpm cd .. alien -r [st3.deb] # 可能会遇到"Issue 2" # 安装rpm包 rpm -ivh [st3.rpm]
"Issue 1": Can't locate ExtUtils/MakeMaker.pm in @INC...linux
yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker -y
"Issue 2": no entry data.tar.gz in archive ... Error executing "ar -p ...git
# 未解决~
参考github
2.1) Package Control:包管理器windows
"ctrl+`"调出控制台,输入标题连接内提供的Code,回车运行便可。于菜单栏"Preferences"下可看到"Package Control"。sublime-text
而后,经过它的"Install Package"安装其余插件。markdown
2.2) SideBarEnhancements:侧边栏右键操做加强app
Preferences > Key Bindings - User,添加快捷:sublime-text-3
{ "keys": ["ctrl+t"], "command": "side_bar_new_file2" }, { "keys": ["f2"], "command": "side_bar_rename" },
2.3) ConvertToUTF8:其余编码支持ide
有个注意事项:
Linux 用户:Sublime Text 2 和 3 内嵌 Python 版本中缺失几个 ConvertToUTF8 依赖的动态库。您必须手工安装这些文件才能让本插件彻底运做。
2.4) SublimeLinter:检查语法错误
好多,选本身要用的语言,如Python的"SublimeLinter-pep8"。
2.5) SublimeCodeIntel:代码提示
安装完成后,会提示你:
For Linux: * Jump to definition = ``Super+Click`` * Jump to definition = ``Control+Super+Alt+Up`` * Go back = ``Control+Super+Alt+Left`` * Manual CodeIntel = ``Control+Shift+space``
C系列语言的话,用SublimeClang。
2.6) Markdown Preview:Markdown预览
设置快捷"ctrl+m+p":
{ "keys": ["ctrl+m", "ctrl+p"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"} },
2.7) InputHelper:输入帮助
Sublime输入不了中文,首先安装中文字体:
# 下载"YaHei.Consolas.1.12.Revise.ttf"字体 mkdir -p /usr/share/fonts/truetype/ # 将下载的字体拷贝到上述目录 fc-cache /usr/share/fonts/truetype # 配置为该字体,见第3节"font_face"
而后安装InputHelper,重启Sublime。以后"Ctrl+Shift+Z",调出对话框,切换输入法,便可输入中文。
若是很不幸没效果的话,能够参考下最后附录:InputHelper插件问题。
Preferences > Settings - User,添加Tab空格及显示:
"draw_white_space": "all", "tab_size": 4, "translate_tabs_to_spaces": true, "font_face": "YaHei Consolas Hybrid",
略。
Step 1: "Ctrl+`"调控制台,"Ctrl+Shift+Z"看输出:
Traceback (most recent call last): File "/opt/sublime_text/sublime_plugin.py", line 549, in run_ return self.run(edit) File "inputhelper in /home/join/.config/sublime-text-3/Installed Packages/InputHelper.sublime-package", line 21, in run File "X/subprocess.py", line 818, in __init__ File "X/subprocess.py", line 1416, in _execute_child FileNotFoundError: [Errno 2] No such file or directory: '/home/join/.config/sublime-text-3/Packages/InputHelper/lib/linux_text_input_gui.py'
Step 2: 解压"Installed Packages/"下"InputHelper.sublime-package"到"Packages/",并删除原包,重启Sublime。以直接用源代码。
Step 3: "Ctrl+Shift+Z"再看输出:
Traceback (most recent call last): File "/opt/sublime_text/sublime_plugin.py", line 549, in run_ return self.run(edit) File "/home/join/.config/sublime-text-3/Packages/InputHelper/inputhelper.py", line 21, in run proc = subprocess.Popen(args, stdout=subprocess.PIPE) File "X/subprocess.py", line 818, in __init__ File "X/subprocess.py", line 1416, in _execute_child PermissionError: [Errno 13] Permission denied
Step 4: 修改"inputhelper.py"添加输出,看Popen了什么。为"InputHelper/lib/linux_text_input_gui.py"。继而查看其权限为"-rw-rw-r--",以下直接改成777:
chmod 777 /home/join/.config/sublime-text-3/Packages/InputHelper/lib/linux_text_input_gui.py
Step 5: 继续"Ctrl+Shift+Z",没效果。直接运行"linux_text_input_gui.py",发现:
ImportError: No module named pygtk
Step 6: "pip install PyGTK"安装pygtk,但:
CompressionError: bz2 module is not available
Step 7: 源于编译Python2.7时没bz2模块,make时会提示缺失"bz2"。编译前安装有bzip2便可:
# 须要bzip2,不论如何,执行下行命令 yum install bzip2 bzip2-devel -y
重编译安装,见CentOS升级Python2.7及安装pip。
Step 8: 从新"pip install PyGTK",而后:
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/PyGTK Storing debug log for failure in /root/.pip/pip.log # 直接从源码安装 wget http://pypi.douban.com/packages/source/P/PyGTK/pygtk-2.24.0.tar.bz2 tar jxvf pygtk-2.24.0.tar.bz2 cd pygtk-2.24.0 python setup.py install # 同样提示错误: # ******************************************************************** # * Building PyGTK using distutils is only supported on windows. * # * To build PyGTK in a supported way, read the INSTALL file. * # ******************************************************************** vi INSTALL # 看来要重编 ./configure # issue: configure: error: Package requirements (pygobject-2.0 >= 2.21.3) were not met: ... No package 'pygobject-2.0' found ... # 缺乏pygobject # yum list pygobject* yum install pygobject2 pygobject2-devel -y # issue: configure: error: Package requirements (pygobject-2.0 >= 2.21.3) were not met: # Requested 'pygobject-2.0 >= 2.21.3' but version of PyGObject is 2.20.0 # pygobject版本不够 rpm -e pygobject2-devel # 下个高版本的PyGObject wget http://ftp.gnome.org/pub/GNOME/sources/pygobject/3.10/pygobject-3.10.2.tar.xz tar Jxvf pygobject-3.10.2.tar.xz cd pygobject-3.10.2
Step 9: 感受很折腾,应该是因为目前为Python2.7才依赖了高版本的PyGObject,因此:
# 而原先Python2.6还装着,因此: vi /home/join/.config/sublime-text-3/Packages/InputHelper/lib/linux_text_input_gui.py # 把第一行改成"#!/usr/bin/env python2.6.6" # 而后"Ctrl+Shift+Z"果然弹出了对话框,但Sublime UI阻塞,未响应。 cd /home/join/.config/sublime-text-3/Packages/InputHelper/lib/ python2.6.6 linux_text_input_gui.py # 输入内容后回车,看到以下错误: # AttributeError: 'gtk.Entry' object has no attribute 'get_buffer' # Traceback (most recent call last): # File "linux_text_input_gui.py", line 14, in destroy # self.print_text() # File "linux_text_input_gui.py", line 9, in print_text # buffer = self.textInput.get_buffer() # AttributeError: 'gtk.Entry' object has no attribute 'get_buffer' # 给"linux_text_input_gui.py"的"SimpleTextInput::print_text()"添加打印,看"self.textInput"的属性。直接有"get_text",因此作以下修改: # def print_text(self): # # buffer = self.textInput.get_buffer() # # print(buffer.get_text()) # print(self.textInput.get_text()) # 问题解决。pygtk版本不一样的缘由么?
Step 10: 折腾死我了,不想活了TT。