分类 开发环境 下的文章

1. sublimectrl + f 弹出搜索框,输入要搜索的单词搜索后,按上下键无法像 phpstorm 一样直接跳转到上一个或者下一个查询结果。

解决方法:

entershift + enter 或者 F3shift + F3 替换上下键。

2. 搜索出结果后,无法将光标移动到搜索结果上面,按 ESC 后虽然可以把光标移过去,但搜索高亮又没了

解决方法:

ctrl + 1,这样子可以保留搜索高亮的同时,还可以修改对应的单词。
同时,这时候还可以按F3 + shift + F3 跳转到上一个、下一个搜索结果

ctrl+shift+p 进入命令行,输入 install package

0. 中文汉化包 (按需)

ChineseLocalization
https://github.com/rexdf/ChineseLocalization

1. 侧边栏展示文件类型图标

AFileIcon
https://github.com/SublimeText/AFileIcon

2. 在侧边栏定位到当前文件

FocusFileOnSidebar
https://github.com/miguelgraz/FocusFileOnSidebar

3. 解决双击变量时,无法选中变量前面的$符号问题

默认情况下sublime双击是不能选中$,比如$value,双击只能选中value而不能连$一起选中。
可以通过修改配置实现:
"word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?",
但是这样设置完,选中$value,其他出现$value的地方不高亮了。
安装下面的插件可以解决
wordHighlight
https://github.com/SublimeText/WordHighlight

4. 语法提示插件,支持多种语言

Anaconda
http://damnwidget.github.io/anaconda/

注意:
安装完之后,需要修改下面配置:
Preferences->Package Settings->Anaconda->Settings Default

  1. 修改python_interpreter为实际Python安装路径(xxx/python.exe)
  2. 修改anaconda_linting值,从默认值true改为false

主题

Preferences -> Settings

{
    "ignored_packages":
    [
        "Vintage",
    ],
    // 主题设置
    "theme": "Default Dark.sublime-theme",
    "color_scheme": "Monokai.sublime-color-scheme",
    "dark_theme": "Adaptive.sublime-theme",
    "light_theme": "Default Dark.sublime-theme",

    // 字体行距设置
    "font_face": ["Consolas","Lucida Sans Typewriter","Courier New"],
    "font_size": 10,
    "line_padding_bottom": 2,
    "line_padding_top": 2,

    // 显示空格跟tab
    "draw_white_space": "all",

    // 关闭单击预览文件功能,防止文件被替换
    "preview_on_click": false,

    // 显示当前文件编码
    "show_encoding": true,

    // 显示当前文件换行符
    "show_line_endings": true,
    /*"font_size": 10,*/

    // 默认情况下sublime双击是不能选中$,
    // 比如$value,双击只能选中value而不能连$一起选中,这里把$符号删掉
    // 但是这样选中$value后,但是其他出现$value的地方不高亮了。
     // 解决:所以如果设置了这个,还需要安装 wordHighlight 插件
    "word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?",
}



快捷键

Preferences -> Key Bindings

[
    //跳转到上一个编辑地方
    { "keys": ["alt+left"], "command": "jump_back" },
    // 跳转到下一个编辑地方
    { "keys": ["alt+right"], "command": "jump_forward" },
    //整行下移
    { "keys": ["alt+down"], "command": "swap_line_down" },
    //整行上移
    { "keys": ["alt+up"], "command": "swap_line_up" },
    //自动提示
    { "keys": ["alt+/"], "command": "auto_complete" },
    // 转换大写
    { "keys": ["ctrl+shift+x"], "command": "upper_case" },
    // 转换小写
    { "keys": ["ctrl+shift+y"], "command": "lower_case" },
    // 删除整行
    { "keys": ["ctrl+d"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
    // 光标移动到指定行
    { "keys": ["ctrl+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
    // 快速定位到选中的文字
    { "keys": ["ctrl+k"], "command": "find_under_expand_skip" },
    // 这个命令默认使用的是ctrl+shift+P
    { "keys": ["ctrl+shift+p"], "command": "show_overlay", "args": {"overlay": "command_palette"} },
    // outline
    { "keys": ["ctrl+o"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} },
    // 当前文件中的关键字(方便快速查找内容)
    { "keys": ["ctrl+alt+o"], "command": "show_overlay", "args": {"overlay": "goto", "text": "#"} },
    // open resource
    { "keys": ["ctrl+shift+r"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
    // 文件内查找/替换
    { "keys": ["ctrl+f"], "command": "show_panel", "args": {"panel": "replace"} },
    // 全局查找/替换, 在查询结果中双击跳转到匹配位置
    {"keys": ["ctrl+shift+h"], "command": "show_panel", "args": {"panel": "find_in_files"} },
    //跳转到定义,比如在某个函数上按此键,则跳转到它的定义
    { "keys": ["ctrl+up"], "command": "goto_definition" },
    // plugin配置
    { "keys": ["alt+a"], "command": "alignment" },
    // 这里使用的是html+css+js prettify插件来格式化
    { "keys": ["ctrl+shift+f"], "command": "htmlprettify" },
    // 选择下一个相同的
    { "keys": ["alt+y"], "command": "find_under_expand" },
    // 注释
    { "keys": ["ctrl+shift+c"], "command": "toggle_comment", "args": { "block": false } },
    
    // 在项目中搜索
    { "keys": ["ctrl+shift+f12"], "command": "show_panel", "args": {"panel": "find_in_files"} },

    // 根据文件名搜索
    { "keys": ["shift", "shift"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },

    //{ "keys": ["shift", "shift"], "command": "show_overlay", "args": { "overlay": "goto", "text": "@" } },
    // 换行展示
    { "keys": ["alt+z"], "command": "toggle_setting", "args": {"setting": "word_wrap"} },

    // markdown预览功能:需要安装两个插件:MarkdownEditing、MarkdownLivePreview
    {"keys": ["alt+m"], "command": "open_markdown_preview"},

    //搜索框按下enter之后,焦点自动定在搜索结果的地方
    //没有快捷键,搜索完按 ctrl+1 可以把光标移过去

    //切换tab
    { "keys": ["ctrl+1"], "command": "select_by_index", "args": { "index": 0 } },
    { "keys": ["ctrl+2"], "command": "select_by_index", "args": { "index": 1 } },
    { "keys": ["ctrl+3"], "command": "select_by_index", "args": { "index": 2 } },
    { "keys": ["ctrl+4"], "command": "select_by_index", "args": { "index": 3 } },
    { "keys": ["ctrl+5"], "command": "select_by_index", "args": { "index": 4 } },
    { "keys": ["ctrl+6"], "command": "select_by_index", "args": { "index": 5 } },
    { "keys": ["ctrl+7"], "command": "select_by_index", "args": { "index": 6 } },
    { "keys": ["ctrl+8"], "command": "select_by_index", "args": { "index": 7 } },
    { "keys": ["ctrl+9"], "command": "select_last_tab" },

    //左右分屏,需要分几个输入数字几,最多分4列,复原的话将2改为1
    {
        "keys": ["alt+shift+2"],
        "command": "set_layout",
        "args":
        {
            "cols": [0.0, 0.5, 1.0],
            "rows": [0.0, 1.0],
            "cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
        }
    },

    //上下分屏,需要分几个输入数字几,最多分4行,复原的话将2改为1
    {
        "keys": ["ctrl+shift+2"],
        "command": "set_layout",
        "args":
        {
            "cols": [0.0, 1.0],
            "rows": [0.0, 0.5, 1.0],
            "cells": [[0, 0, 1, 1], [0, 1, 1, 2]]
        }
    },
    {
        "keys": ["ctrl+shift+3"],
        "command": "set_layout",
        "args":
        {
            "cols": [0.0, 1.0],
            "rows": [0.0, 0.33, 0.66, 1.0],
            "cells": [[0, 0, 1, 1], [0, 1, 1, 2], [0, 2, 1, 3]]
        }
    },
    {
        "keys": ["ctrl+shift+1"],
        "command": "set_layout",
        "args":
        {
            "cols": [0.0, 1.0],
            "rows": [0.0, 1.0],
            "cells": [[0, 0, 1, 1]]
        }
    },
]




用了 letsencrypt 的免费证书,过期前忘记续,过期后使用 certbot renew 提示续签失败。

最后用下面步骤解决:

  1. 先停掉 nginx
    nginx -s stop
  2. 进行续签,由于 nginx 配置文件不在默认位置,指定了位置
    certbot renew --nginx --nginx-server-root=/usr/local/openresty/nginx/conf

这里遇到了一个问题,cdn 域名无法续签,添加了 --dry-run 参数打印详细内容(certbot renew --dry-run):

Hint: 
The Certificate Authority failed to verify the temporary nginx configuration changes made by Certbot. 
Ensure the listed domains point to this nginx server and that it is accessible from the internet.

这是因为 cdn 域名指向了供应商的机器,而不是自己的机器。
cdn 域名临时指回自己机器后重新 执行 certbot renew 后解决改问题
最后再把 cdn 域名重新指向供应商。

1. 将 nginx root 配置到 golang 项目的静态文件目录

    server {
        ...
        root /usr/share/public;
        ...
    }

2. 用 location @name 定义一个 location 用于 golang 处理

3. 用 try_files 判断 url 文件是否存在,不存在则丢给 golang 处理

4. 例子如下:

server {
    listen 80;
    server_name  xxx.sshaonan.com;
    root         /usr/share/public;
    #charset utf-8;

    index index.html index.htm;
    try_files $uri @web; 

    location @web {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host            $http_host;
        proxy_pass http://127.0.0.1:3000; 
    }
}