Sublime Text 3的安装配置

1 minute read

发布于:

Sublime是一个非常好用的文本编辑器和IDE,类似于windows下的editplus。并且有丰富的插件可以选择。Ubuntu18.04系统安装配置Sublime Text 3方法如下。

1.添加源和key

wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt-add-repository "deb https://download.sublimetext.com/ apt/stable/"

2.安装

sudo apt install sublime-text

下面进行配置Sublime的工作:

1.启动后点击Tools->Install Package Control安装Package Control组件。在Perferences->中看到package control这一项,则表示安装成功。

2.按ctrl+shift+p调出命令输入面板,输入install,在下面列表框选择Package Control:Install Package这项并回车。然后输入要安装的插件名字,如:Filebrowser等。

3.编辑快捷键,点击菜单Preferences->Key Bindings,在右侧编辑快捷键,我这里的配置如下所示:

[
	{
	  "keys": ["f1"],
	  "command": "dired",
	  "args": {
	    "immediate": true,
	    "single_pane": true,
	    "other_group": "left",
	    "project": true
	  	}
	},
	{ "keys": ["ctrl+1"], "command": "build" }
]

以上定义了两项快捷键,F1用于启动FileBrowser的窗口,定义窗口位置在左边。ctrl+1用于编译。

4.编辑setting项目,点击菜单Preferences->Settings,在右侧编辑设置,如下:

{
	"default_encoding": "UTF-8",
	"draw_white_space": "all",
	"font_size": 11,
	"ignored_packages":
	[
		"Vintage"
	],
	"show_encoding": true,
	"show_line_endings": true,
	"tab_size": 4,
	"translate_tabs_to_spaces": true,
	"update_check": false,
	"word_wrap": true
}

定义字符编码等。

5.解决不能输入中文问题。

git clone https://github.com/lyfeyaj/sublime-text-imfix.git
cd sublime-text-imfix && ./sublime-imfix

安装插件

sublime有很多有用的插件,我最长用的是filebrowser和conda。

Filebrowser插件会在窗口创建一个文件夹面板,可以方便的选取文件。按快捷键ctrl+shift+p打开命令面板,输入Package Control:Install Package并回车,然后输入filebrowser回车进行安装。安装后可以对其进行设置,比如面板打开的位置在左边还是右边,打开面板快捷键等。我的设置如下:

[
	{
	  "keys": ["f1"],
	  "command": "dired",
	  "args": {
	    "immediate": true,
	    "single_pane": true,
	    "other_group": "left",
	    "project": true
	  	}
	}
]

面板打开后出现在窗口左边,快捷键为F1。

Conda插件可以方便的让你在各种conda创建的python环境之间切换。安装方法同上,安装完后在Tools->Build System里面选择conda。然后编译文件前选择激活正确的环境:ctrl+shift+p 调出命令面板,输入conda选择Conda: Activate Environment回车,选择你想激活的环境后回车。如果出现错误可能是conda的配置出错了,可以通过Preferences->Package settings->Conda->Settings-user菜单打开配置文件进行配置,我的配置如下:

// Default settings for sublime-text-conda:
{
    // executable is the path to anaconda's python
    // this python executable is used in order to find conda
    "executable": "~/anaconda3/bin/python3",

    // Directory in which the conda envs are stored
    // Default location is the user's home directory
    "environment_directory": "~/anaconda3/envs/",

    // configuration is the path to conda's configuration file
    "configuration": "/home/glacier/.condarc"
}