sublime text 3 使用汇总 (包含ubuntu下 搜狗输入)

起因是 想要用
{ "keys": [""], "command": "jump_back" },

下载安装包和包管理器

官网下载deb

$:~/Downloads$ sudo dpkg -i sublime-text_build-3065_amd64.deb

包管理器:http://jingyan.baidu.com/article/d3b74d64a302631f77e609fa.html

插件们

https://packagecontrol.io/installation
上面 可以查到最新的插件们

要说和 sublime text 2 最大的不同是 我无法直接 在 package 下面找到插件们的安装包了,所以里面的配置要改起来很麻烦!!
st3 把 原来 放在 package 下面的安装包都放到了 Install package下面,打成 zip的压缩包了(要不要这么作)

可以先装一下 PackageResourceViewer 这个插件,用这个插件来修改之前在安装包里的文件了。
一旦这个安装包中修改过的文件,都会出现在Package文件夹中,方便你下次修改。 (还是比起之前的麻烦很多!!)

看st2 文档

其实这个上面快捷键理解比较全: http://docs.sublimetext.info/en/latest/file_management/file_management.html

markdown Preview
emmet
console.log snippet
Alignment
Bracket​Highlighter // 括号匹配 http://www.dbpoo.com/sublime-text3-brackethighlighter/
DocBlockr // 注释函数代码
html5
colorPicker
open in Browser: use chrome
clickable Url 在st3 下遇到问题,打开 st3 时已经打开的tab 页面是没有识别 url,如果要用需要重新打开(关闭tab: ctrl+w, 重新打开tab: ctrl+shift+t)
twig
inputHelper 安装有时候会没有反应,直接 去 ~/.config/st3/Package/ 下面git clone 的方式 手动安装 不容易出错. (最近sogou好像终于可以很好的支持ubuntu了,可以尝试换用 sougou)

新加

主要是 https://packagecontrol.io/browse/popular 又物色了几个,还有一些是 只兼容 st2,需要替换下。

All Autocomplete //对所有已打开的文档进行补全 You just DO WHAT THE FUCK YOU WANT TO.
Color Highlighter st3可以安装。不过搭配 使用 colorPicker 在ubuntu下始终有点问题,不推荐
Block Cursor Everywhere vim 模式下的光标
Power​Cursors 尝试一下
Sublimerge Pro 新版比较好一点,按 left 是 左边的改,按 right 是 右边的改, ctrl + enter 切换编辑模式,没找到回退功能
Auto​File​Name 如果你在html页面需要添加 一个图片路径,输入了src之后他会为你补全该文件夹下的文件名。
Goto-CSS-Declaration ubuntu 下面使用 win + left , right 还挺好用的。 但要打开 css文件
Vintageous 是 st3 下 vintage的扩展,不过因为涉及了太多的快捷键,最后没有使用。
*主题自行选择
我使用了 http://www.imjeff.cn/blog/146/ 里面 soda 主题 搭配 monikai-extend + markdown-extend

Vintage

v模式下, 我禁用一些快捷键

u 和 U,想要用的时候可以用 sublime 自己的 ctrl + kU 和 ctrl + kl 代替

    // { "keys": ["u"], "command": "visual_lower_case",
    //     "context":
    //     [
    //         {"key": "setting.command_mode"},
    //         {"key": "selection_empty", "operator": "equal", "operand": false, "match_all": false}
    //     ]
    // },

    // { "keys": ["U"], "command": "visual_upper_case",
    //     "context":
    //     [
    //         {"key": "setting.command_mode"},
    //         {"key": "selection_empty", "operator": "equal", "operand": false, "match_all": false}
    //     ]
    // },

    // { "keys": ["ctrl+u"], "command": "vi_scroll_lines",
    //     "args": {"forward": false},
    //     "context": [{"key": "setting.command_mode"}, {"key": "setting.vintage_ctrl_keys"}]
    // },

    // { "keys": ["ctrl+d"], "command": "vi_scroll_lines",
    //     "args": {"forward": true},
    //     "context": [{"key": "setting.command_mode"}, {"key": "setting.vintage_ctrl_keys"}]
    // },

setting

{
    "color_scheme": "Packages/Monokai Extended/Monokai Extended.tmTheme",
    "detect_indentation": true,
    "font_size": 16,
    "highlight_line": true,
    "ignored_packages":
    [
        "Vintage"
    ],
    "tab_size": 4,
    "theme": "Soda Dark 3.sublime-theme",
    "translate_tabs_to_spaces": true,
    "word_separators": "./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}`~?,。:;‘’“”、?!¥…()—《》「」『』【】"
}

keymap

在 st3 下 alt来移动,明显不如st2 灵敏

[
    { "keys": ["alt+q"], "command": "jump_back" },
    { "keys": ["alt+w"], "command": "jump_forward" },

    // PlainTasks
    { "keys": ["ctrl+shift+c"], "command": "plain_tasks_cancel", "context": [{"key": "selector", "operator": "equal", "operand": "text.todo" }] },
    { "keys": ["ctrl+shift+alt+a"], "command": "plain_tasks_archive","context": [{ "key": "selector", "operator": "equal", "operand": "text.todo" }] },

    // vim
    {   
        "keys": ["i","i"], "command": "exit_insert_mode",
        "context":
        [
            { "key": "setting.command_mode", "operand": false },
            { "key": "setting.is_widget", "operand": false }
        ]
    },

    // BracketHighlighter
    // Select text between brackets
    {
        "no_outside_adj": true,
        "keys": ["ctrl+shift+m"],
        "command": "bh_key",
        "args":
        {
            "lines" : true,
            "plugin":
            {
                "type": ["__all__"],
                "command": "bh_modules.bracketselect"
            }
        }
    },
    // Fold contents between brackets 
    // will conver system default
    {
        "keys": ["ctrl+shift+["],
        "command": "bh_key",
        "args":
        {
            "plugin": {
                "type": ["__all__"],
                "command" : "bh_modules.foldbracket"
            }
        }
    },


    // color picker
    { "keys": ["alt+c"], "command": "color_pick" },
    // click url
    { "keys": ["alt+u"], "command": "open_url" },

    // move cursor 
    // 上下移动 一行
    { "keys": ["ctrl+shift+alt+k"], "command": "swap_line_up" },
    { "keys": ["ctrl+shift+alt+j"], "command": "swap_line_down" },

    // 上下左右移动
    { "keys": ["alt+h"], "command": "move", "args": {"by": "characters", "forward": false} },
    { "keys": ["alt+l"], "command": "move", "args": {"by": "characters", "forward": true} },
    { "keys": ["alt+k"], "command": "move", "args": {"by": "lines", "forward": false} },
    { "keys": ["alt+j"], "command": "move", "args": {"by": "lines", "forward": true} },
    // 上下左右移动并选择
    { "keys": ["alt+shift+h"], "command": "move", "args": {"by": "characters", "forward": false, "extend": true} },
    { "keys": ["alt+shift+l"], "command": "move", "args": {"by": "characters", "forward": true, "extend": true} },
    { "keys": ["alt+shift+k"], "command": "move", "args": {"by": "lines", "forward": false, "extend": true} },
    { "keys": ["alt+shift+j"], "command": "move", "args": {"by": "lines", "forward": true, "extend": true} },

    // 左右移动至上/下一个词
    { "keys": ["alt+m"], "command": "move", "args": {"by": "words", "forward": false} },
    { "keys": ["alt+n"], "command": "move", "args": {"by": "words", "forward": true} },

    // 左右移动至上/下一个词并选择
    { "keys": ["shift+alt+m"], "command": "move", "args": {"by": "words", "forward": false, "extend": true} },
    { "keys": ["shift+alt+n"], "command": "move", "args": {"by": "word_ends", "forward": true, "extend": true} },

    // 屏幕按行上/下滚动
    { "keys": ["ctrl+alt+k"], "command": "scroll_lines", "args": {"amount": 10.0 } },
    { "keys": ["ctrl+alt+j"], "command": "scroll_lines", "args": {"amount": -10.0 } },

    { "keys": ["alt+i"], "command": "move_to", "args": {"to": "bol", "extend": false} },
    { "keys": ["alt+o"], "command": "move_to", "args": {"to": "eol", "extend": false} },

    { "keys": ["shift+alt+i"], "command": "move_to", "args": {"to": "bol", "extend": true} },
    { "keys": ["shift+alt+o"], "command": "move_to", "args": {"to": "eol", "extend": true} },

    { "keys": ["ctrl+alt+i"], "command": "move_to", "args": {"to": "bof", "extend": false} },
    { "keys": ["ctrl+alt+o"], "command": "move_to", "args": {"to": "eof", "extend": false} },

    { "keys": ["shift+ctrl+alt+i"], "command": "move_to", "args": {"to": "bof", "extend": true} },
    { "keys": ["shift+ctrl+alt+o"], "command": "move_to", "args": {"to": "eof", "extend": true} },

    // 格式化
    { "keys": ["ctrl+="], "command": "reindent" }
]

ubuntu 下的搜狗输入

饱受折磨,在sublime里面输入中文,随着 国产linux系统的开发,中文输入法已经可以越来越好的支持 ubuntu了, 下面的内容摘自网络。

http://jingyan.baidu.com/article/f3ad7d0ff8731609c3345b3b.html
http://jingyan.baidu.com/article/da1091fbd695e2027849d6f6.html

(在ubuntu12.04下测试通过)

在 ~ 目录下 ,没有的话新建 文件名:sublime_imfix.c
里面的内容

#include <gtk/gtkimcontext.h>                                               
void gtk_im_context_set_client_window (GtkIMContext *context, GdkWindow *window)
{
    GtkIMContextClass *klass;
    g_return_if_fail (GTK_IS_IM_CONTEXT (context));
    klass = GTK_IM_CONTEXT_GET_CLASS (context);
    if (klass->set_client_window)
        klass->set_client_window (context, window);
    g_object_set_data(G_OBJECT(context),"window",window);

    if(!GDK_IS_WINDOW (window))
        return;
    int width = gdk_window_get_width(window);
    int height = gdk_window_get_height(window);
    if(width != 0 && height !=0)
        gtk_im_context_focus_in(context);
}

自己编译共享库,编译前确保安装了以下:

sudo apt-get install build-essential
sudo apt-get install libgtk2.0-dev

将sublime_imfix.c 编译成共享库libsublime-imfix.so,命令

cd ~
gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk+-2.0` -fPIC

把编译好的libsublime-imfix.so 复制到sublime_text_3安装目录下 大概是在 /opt/sublime-text/ 下

sudo mv libsublime-imfix.so /opt/sublime_text/

修改文件/usr/bin/subl的内容, 最后该文件 为下面内容:

#!/bin/sh                                                                   
export LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so 
exec /opt/sublime_text/sublime_text "$@"

此时,在命令中执行 subl 将可以使用搜狗for linux的中文输入.

posted @ 2015-01-14 11:33  tuziguaiguai  阅读(442)  评论(0编辑  收藏  举报