1、錄制一份macro
caret on a word –> ctrl+left –> ctrl+shift+right
2、將錄制好的macro保存為select_current_word.sublime_macro
3、在sublime text 3中的Preferences菜單中找到Keybindings,然后在user的keymap中加入以下快捷鍵映射信息:
[
…
{ "keys": ["ctrl+e"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["ctrl+shift+k"], "command": "slurp_find_string" },
{ "keys": ["alt+up"], "command": "swap_line_up" },
{ "keys": ["alt+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+right"], "command": "run_macro_file", "args": {"file": "res://Packages/User/select_current_word.sublime-macro"} }]
ctrl+e為刪除當前行;
alt+up為將當前行與其上一行交換位置;
alt+down為將當前行與其下一行交換位置;
ctrl+right為執行指定的宏文件。
注:
有一個弊端。當光標置於一個單詞的第一個字符前面時,執行ctrl+right將選定單詞前的空格部分。