[Sublime Text3] 随记

本文档详细介绍了Sublime Text3的安装、配置过程,包括安装Package Control,推荐的常用插件如ConvertToUTF8、Emmet、JsFormat等,以及快捷键的使用和Python3的配置。此外,还提到了Material Theme主题的设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Sublime Text3

一、安装配置

下载地址

http://www.sublimetext.com/3

安装Package Control

方法一:[View] -> [Show Console] 填入以下,然后enter;安装后重启

import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; 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)

方法二:下载安装
https://packagecontrol.io/installation
wget https://packagecontrol.io/Package%20Control.sublime-package
下载Package Control.sublime-package至Installed Packages,重启
在这里插入图片描述
安装完以后,Ctrl+Shift+p 输入install Package回车就可以安装插件

二、常用插件

ConvertToUTF8

通过本插件,可以编辑并保存目前编码不被 Sublime Text 支持的文件,特别是中日韩用户使用的 GB2312,GBK,BIG5,EUC-KR,EUC-JP 等
[File]->[Set File Encoding to]->[UTF-8] 设置文件格式

Emmet

前端必备.这个不需要做多介绍,网上搜索一下有很多相关使用教程。还有一个拓展小插件,叫做 Emmet LiveStyle,需要和 Google Chrome 浏览器搭配使用,具体使用方法可以去官网看视频演示。

JsFormat

JS 格式化插件.作为 nodejs 开发的必备神器。使用快捷键Command + Option + F或者在命令面板(Command + Shift + P)输入Format: Javascript就可以使用格式化命令。

Bracket Highlighter

用于匹配括号,引号和 html 标签。对于很长的代码很有用。

DocBlockr

可以自动生成PHPDoc风格的注释。它支持的语言有Javascript, PHP, ActionScript, CoffeeScript, Java, Objective C, C, C++。
输入"/*"+Tab可以自动生成注释

SublimeREPL

实现python交互功能
Python3需要拷贝一份修改配置;设置快捷键

Material Theme

主题配色
[Preferences]->[Settings]设置主题配置

三、快捷键

运行

command+shift+b         SublimeREPL运行脚本
command+shift+c         打开python console
command+shift+p         开package control
ctrl+alt+enter          Emmet快速插入HTML
command+b               编译

打开关闭

command+N               新建新文件
command+O               打开文件
command+W               关闭文件
command+shift+T         打开最近关闭文件
command+shift+N         新建新窗口
command+shift+W         关闭窗口
ctrl+`                  打开console
ctrl+Tab                切换窗口

选择

command+A               全选
command+D               选中光标单词
command+L               选中一行,继续选中下一行,同Shift+↓
shift+↑/↓               向上/下选中多行
shift+←/→               向左/右选中文本(字符单位)
command+shift+←/→       向左/右选中行内所有文本
command+shift+↑/↓       向左/右选中文件内所有文本
ctrl+shift+M            选中括号内内容

编辑

command+shift+L         选中后,操作会在每行后插入光标,同时编辑这些行
ctrl+shift+↑/↓          添加多行光标,可同时编辑多行
command+Enter           在下一行插入一行
command+shift+Enter     在上一行插入一行
ctrl+shift+K            删除行
command+K+K             删除至行尾
command+shift+D         复制粘贴当前行
command+K+U             单词大写
command+K+L             单词小写
command+C               复制
command+V               粘贴
command+shift+V         粘贴并自动缩进
command+option+V        从历史中选择粘贴
command+X               剪切
command+Z               撤销
command+Y               恢复撤销
command+S               保存
command+/               注释
command+]               右缩进,相当于Tab
command+[               左缩进,相当于shift+Tab

搜索

command+F               查找文本
command+G               查找下一个
command+shift+G         查找上一个
command+ctrl+G          匹配所有项
command+option+F        查找替换
command+shift+F         所有文件查找,按enter列出所有匹配
command+P/T             搜索跳转,前往文件、项目、函数、变量等
    搜索框:输入 @+函数名;:+数字行号;#+关键字变量名
command+ctrl+P          前往project
command+R               前往函数
command+shift+P         前往命令提示
ctrl+G                  前往行
ctrl+-                  光标跳转上一处
ctrl+M                  跳转匹配括号
command+←/→             光标跳到行首/行尾

四、Python3配置

语法高亮

[View]->[Syntax]->[Python]

New Build

[Tools]->[Build System]->[New Build System]
在这里插入图片描述
保存为Python3.sublime-build
然后[Tools]->[Build System]->[New Build System]选Python3
在这里插入图片描述

SublimeREPL

  1. 安装
    command + shift + p 打开命令提示框,输入Install Package,安装SublimeREPL
    安装后[Tools]->[SublimeREPL]
  2. 配置
    [Preferences] > [Browse Packages]打开,找到SublimeREPL的config,将Python目录拷贝一份Python3
[
    {
        "caption": "SublimeREPL: Python3",
        "command": "run_existing_window_command", "args":
        {
            "id": "repl_python3",
            "file": "config/Python3/Main.sublime-menu"
        }
    },
    {
        "caption": "SublimeREPL: Python3 - PDB current file",
        "command": "run_existing_window_command", "args":
        {
            "id": "repl_python_pdb",
            "file": "config/Python3/Main.sublime-menu"
        }
    },
    {
        "caption": "SublimeREPL: Python3 - RUN current file",
        "command": "run_existing_window_command", "args":
        {
            "id": "repl_python_run",
            "file": "config/Python3/Main.sublime-menu"
        }
    },
    {
        "command": "python_virtualenv_repl",
        "caption": "SublimeREPL: Python3 - virtualenv"
    },
    {
        "caption": "SublimeREPL: Python3 - IPython",
        "command": "run_existing_window_command", "args":
        {
            "id": "repl_python_ipython",
            "file": "config/Python3/Main.sublime-menu"
        }
    }
]
[
     {
        "id": "tools",
        "children":
        [{
            "caption": "SublimeREPL",
            "mnemonic": "R",
            "id": "SublimeREPL",
            "children":
            [
                {"caption": "Python3",
                "id": "Python3",

                 "children":[
                    {"command": "repl_open",
                     "caption": "Python3",
                     "id": "repl_python3",
                     "mnemonic": "P",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "cmd": ["python3", "-i", "-u"],
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python3",
                        "extend_env": {"PYTHONIOENCODING": "utf-8"}
                        }
                    },
                    {"command": "python_virtualenv_repl",
                     "id": "python_virtualenv_repl",
                     "caption": "Python - virtualenv"},
                    {"command": "repl_open",
                     "caption": "Python - PDB current file",
                     "id": "repl_python_pdb",
                     "mnemonic": "D",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "cmd": ["python3", "-i", "-u", "-m", "pdb", "$file_basename"],
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python3",
                        "extend_env": {"PYTHONIOENCODING": "utf-8"}
                        }
                    },
                    {"command": "repl_open",
                     "caption": "Python - RUN current file",
                     "id": "repl_python_run",
                     "mnemonic": "R",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "cmd": ["python3", "-u", "$file_basename"],
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python3",
                        "extend_env": {"PYTHONIOENCODING": "utf-8"}
                        }
                    },
                    {"command": "repl_open",
                     "caption": "Python - IPython",
                     "id": "repl_python_ipython",
                     "mnemonic": "I",
                     "args": {
                        "type": "subprocess",
                        "encoding": "utf8",
                        "autocomplete_server": true,
                        "cmd": {
                            "osx": ["python3", "-u", "${packages}/SublimeREPL/config/Python3/ipy_repl.py"],
                            "linux": ["python3", "-u", "${packages}/SublimeREPL/config/Python3/ipy_repl.py"],
                            "windows": ["python3", "-u", "${packages}/SublimeREPL/config/Python3/ipy_repl.py"]
                        },
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python3",
                        "extend_env": {
                            "PYTHONIOENCODING": "utf-8",
                            "SUBLIMEREPL_EDITOR": "$editor"
                        }
                    }
                    }
                ]}
            ]
        }]
    }
]
  1. 快捷键
    [Preferences] -> [Key Bindings]
[ 
    {
    "keys":["command+shift+b"],
    "caption": "SublimeREPL: Python3 - RUN current file",
    "command": "run_existing_window_command", "args": {"id": "repl_python_run",
    "file": "config/Python3/Main.sublime-menu"}
    }
]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值