惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
InfoQ
C
CERT Recently Published Vulnerability Notes
The Last Watchdog
The Last Watchdog
P
Proofpoint News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
P
Privacy & Cybersecurity Law Blog
Simon Willison's Weblog
Simon Willison's Weblog
Jina AI
Jina AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
博客园_首页
F
Fortinet All Blogs
博客园 - Franky
Latest news
Latest news
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
D
Docker
Project Zero
Project Zero
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
Cisco Talos Blog
Cisco Talos Blog
Y
Y Combinator Blog
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
H
Help Net Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
PCI Perspectives
PCI Perspectives
Cloudbric
Cloudbric
V
Visual Studio Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN Mintty Tips and Configurations Generating Table of Contents for Markdown with Tagbar Convert Python Script to Exe on Windows with Pyinstaller Ubuntu on Windows Missing after Windows Update 使用代理加速 Mac 终端下载速度 My Experience with Several Zsh Plugin Managers 深圳租房小记 How to Install zplug inside Docker Container Why don't settings inside bashrc or bash_profile take effect? Setting Up Locale in Linux 谷歌 Adsense 申请及在 Hugo 中的配置 How to Write Algorithm Pseudo Code in LaTeX Nifty Nvim Techniques That Make My Life Easier -- Series 4 A Few Grammar Questions in Writing How to Read and Write Images with Unicode Paths in OpenCV Creating A Professional Table in LaTeX with booktabs How to Create Proper Folding for Vim/Nvim Configuration Linux Tips and Tricks -- s1 JPEG Image Orientation and Exif How Do I Show the Current File Path In Neovim? JPEG Image Quality in PIL Difference between view, reshape, transpose and permute in PyTorch Convert PIL or OpenCV Image to Bytes without Saving to Disk Fast Movement and Navigation Inside Vim or Neovim Unintuitive Behaviour of Case Sensitivity in Python glob Binding Keys in Zsh 几把机械键盘试用体验 Nvim Autocompletion with Deoplete Converting Markdown to Beautiful PDF with Pandoc Exclusive and Inclusive Motion in Neovim/Vim Nifty Nvim Techniques Which Make My Life Easier -- Series 3 Why Doesn't Jedi Autocompletion Work for Some Methods Vim-like Editing inside Browser Markdown 生成 HTML 时汉字之间出现多余空格问题 小米 9 安装谷歌商店(Google Play Store)与相关配置 Create Mappings That Take A Count in Neovim Spell Checking in Nvim English Words Completion inside Neovim/Vim How to Use Python Inside Vim Script with Neovim Nifty Little Nvim Techniques to Make My Life Easier -- Series 2 Setting up Ultisnips for Neovim Mac 上罗技 M590 鼠标设置 Nifty Little Nvim Techniques to Make My Life Easier -- Series 1 A Complete Guide on Writing LaTeX with Vimtex in Neovim Manipulating Images with Alpha Channels in Pillow Sublime Text Regular Expression Cheat Sheet Cropping Rotated Rectangles from Image with OpenCV Boosting Your Productivity on Terminal with Zsh and Plugins 最新版 Rime 输入法使用 (2022 更新) Display Image with Pillow inside Ubuntu on Windows Faster Directory Navigation with z.lua Cmder Advanced Configurations Nvim-qt Settings on Windows 10 Tmux Plugin Install and Management How to Debug Python Code in Terminal Markdown Writing and Previewing in Neovim -- A Complete Guide Line Number Settings for More Efficient Movement in Neovim 两个大规模中文语料库介绍以及处理 Windows 系统下几款程序员不可不用的神器 我的 2018 阅读清单 A Complete Guide to Neovim Configuration for Python Development How Is Newline Handled in Python and Various Editors? Two Issues Related to ImageFont Module in PIL 在 Listary 中调用 GoldenDict 或欧路词典查单词 Reading and Writing Text Files on Windows The Mathematics behind Font Shapes --- Bézier Curves and More 快速识别图片字体:字体识别工具介绍 Deoplete Failed to Load at Startup after Updating Python neovim Package What Is The Difference between pip, pip3 and pip3.6 Shipped with Anaconda3? Windows 10 系统下 Neovim 安装与配置
Sublime Text 3 使用相关问题及解决办法
2017-03-19 · via jdhao's digital space

这篇文章集中写一些在使用 Sublime Text 3 时遇到的问题以及解决办法,某些问题在不 同系统的解决办法可能都是一样的,但是未经测试,所以使用的时候请先验证。

打开中文文件乱码 [Windows, Linux]#

如果中文文件是使用的 GBK 等中文独有的编码方式 ,而不是通用的 UTF-8 编码,使用 Sublime Text 打开以后会发现文件显示乱码,因为 Sublime Text 目前为止并不原生支持 GBK 等中文编码。 好在有一款 Sublime Text 的插件,可以帮助解决这个问题。 这款插 件名字叫 “ConvertToUTF8”, 安装好以后打开中文编码文件就可以自动转换为 UTF-8 编码,值得注意的是关闭文件以后 ,这个库默认把 UTF-8 编码再转为该文件初始编码,如果不想要这种行为,可以通过设定 "convert_on_save" : false 来关闭这项功能。 如果不想下载这个插件,用系统自带的 记事本打开文件,然后另存为 UTF-8 编码也可以。

新建一个 build system,编译运行 C++ 文件[Linux, Windows]#

Sublime Text 3 自带 CPP 的 build system: “C++ Single File”,但是这个 build system 只能编译,不能直接运行编译好的程序,所以运行简单的 CPP 文件有点麻烦,编 译好以后,还需要自己去 shell 里面运行。 我们可以新建一个简单的 build system,实 现自己的需求,依次点击 “Tools–>Build System–>New Build System”,使用下面的配 置

{
"cmd" : ["g++ -std=c++11 -Wall ${file_name} -o ${file_base_name} && ./${file_base_name}"], 
"selector" : "source.c",
"shell": true,
"working_dir" : "$file_path"
}

如何使程序直接在系统的 terminal 或者 console 运行#

Sublime Text 运行需要从 standard input (一般来说就是 console) 输入数据的程序时 ,该程序无法正常接收输入,如何解决这个问题呢? 我们可以给编译 C++ 增加一个可选 的方式,Sublime Text 里面称为 “variants”,然后指定在 GUI terminal 里面运行编译 好的文件。 Linux 系统与 Windows 系统设置稍有不同。

Linux 配置#

完整的配置文件如下

{
    "shell_cmd": "g++ -std=c++11 -Wall \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c++, source.cpp, source.cc, source.cxx",

    "variants":
    [
        {
            "name": "Run in Terminal",
            "shell_cmd": "g++ -std=c++11 -Wall \"${file}\" -o \"${file_path}/${file_base_name}\" && xterm -e '${file_path}/${file_base_name} && echo && echo Press ENTER to continue && read line && exit'",
           // "shell_cmd": "gnome-terminal -e 'bash -c \"${file_path}/${file_base_name}&& echo && echo Press ENTER to continue && read line && exit\"'", // for gnome-terminal 
           // "shell_cmd": "xterm -e '${file_path}/${file_base_name}; bash'", // for xterm
           // "shell_cmd": "xterm -hold -e ${file_path}/${file_base_name}", // for xterm
           // "shell_cmd": "konsole --hold -e ${file_path}/./${file_base_name}", // for konsole
            "shell": true,
        },
    ]
}

上述配置文件提供了针对 genome-terminal, xterm, Konsole 的配置,可以按照自己正在 使用的 GUI terminal 选择对应的配置。 上述配置还可以保证程序在运行结束以后, terminal 的窗口不会立即关闭。 当运行需要从 console 输入数据的程序时,直接使用 CTRL + SHIFT + B 快捷键,然后选择 Run in Terminal 选项即可。

Windows 配置#

以上的配置针对的 Linux 系统,如果你使用的是 Windows 系统,情况会稍有不同,下面 的配置是适用于 Windows 的配置,

{
    "shell_cmd": "g++ -Wall -std=c++11 \"${file}\" -o \"${file_path}/${file_base_name}.exe\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c++",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd":"\"${file_path}/${file_base_name}\""
        },
        {
            "name": "Run in CMD",
            "shell_cmd":   "start cmd /k  $file_base_name "
            // "shell_cmd":   "start \"$file_base_name\" call $file_base_name"
        }
    ]
}

使用 CTRL + B 来编译源代码,然后使用 CTRL + SHIFT + B 来选择在 Sublime Text 的 console 运行还是直接在 Windows CMD 窗口运行,上述的配置也可以保证程序运行以 后,terminal 的窗口不会自动关闭,方便用户查看输出结果。

输入法图标不跟随输入光标#

在 Sublime Text 中使用中文时,发现输入法的候选字的框不跟随输入光标,这个 bug 官 方没有解决,有一个插件 IMESupport 可以解决这个问题。

更改 package 的 user setting,保存的时候一直提示 “Unexpect trailing characters”[Windows, Linux]#

安装了一个 package 以后,需要进行个性化设置,然后保存设置的时候一直提示错误,错 误信息如下

Error trying to parse settings: unexpected trailing characters

这个原因是输入的 setting 不是有效的 JSON 格式,我的问题是忘记在 setting 外加大 括号了。例如下面的 setting 就是有问题的

    // Convert when previewing file: true or false
    "preview_action" : false,

正确的写法应该是

{
 // Convert when previewing file: true or false
    "preview_action" : false,
}

新建一个 snippet [Windows, Linux]#

所谓 snippet,简单来说就是一个代码片段,你为这个 snippet 设立一个关键词,当你输 入关键词以后,就会激活这个 snippet,省去了重复输入的麻烦。 在编写 C++ 程序的时 候每次都需要输入头文件,using declaration,比较麻烦,可以创立一个 snippet,建立 好 CPP 文件以后输入关键词,自动填充预定义的模板。 建立方法如下,依次打开Tools -> Developer -> New Snippet..., 在生成的文件里填写如下内容,

<snippet>
    <content><![CDATA[
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using std::cout;
using std::vector;
using std::string;

int main(){
    return 0;
}

]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>cpp</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.python</scope> -->
</snippet>

然后给创建的 snippet 起一个名字,如 C++_default_template.sublime-snippet, 然 后在文件中输入 cpp,再点击Tab,就会直接输入对应的 snippet。

如何编辑 Sublime Text 自带的 build system [Windows, Linux]#

在 Sublime Text 中,package 都是以 .sublime-package 的压缩文件形式存在,以 C++ build system 为例,如果要编辑 Sublime Text 自带的 C++ build system,首先要 安装 PackageResourceViewer ,然后使用 Ctrl+Shift+P,打开 Package Control 的窗口,输入 prv, 选择 Open Resource,然后输入 C++,向下移动光标,选择 C++ Single File.sublime-build,打开这个文件,按照自己意愿编辑,编辑以后保存就 可以了。

使用 Package Control 安装插件的时候提示 “There are no packages available for installation”[Windows, Linux]#

问题如题所示,重装 Package Control 解决了这个问题。 首先,卸载 Package Control ,然后,重新安装 Package Control

使用 Ctrl + backtick 无法打开 console[Windows, Linux]#

Sublime Text 默认打开 console 的快捷键 (shortcut) 是 Ctrl+`,但是在我的系统上,按这个组合键,没有任何反应, 根据 Stackoverflow 上的回答 , 点击打开 console,然后输入 sublime.log_input(True), 监听按键,发现按下 Ctrl+` 时,Sublime 并未记录到按键。于是根据别人的答案, 自己设置了另外一个快捷键组合 Ctrl+ 来打开 console, 在自 己的 user key binding 设置里面加上一项:

    { "keys": ["ctrl+'"], "command": "show_panel", "args": {"panel": "console", "toggle": true} },

参考#