解决方案 #1 -- Sublime Text 2:
无论出于何种原因,super+d aka ⌘+d aka find_under_expand 都不使用宏。 find_under_expand 似乎不是插件。因此,这是一个使用宏的示例 select-entire-word 插件:
import sublime, sublime_plugin
class Expand(sublime_plugin.TextCommand):
def run(self, edit):
regions = []
for s in self.view.sel():
word = self.view.word(sublime.Region(s.begin(), s.end()))
if word.end() == s.end():
# to deal with an end of line issue
word = self.view.word(sublime.Region(s.end(), s.end() + 1))
regions.append(word)
for r in regions:
self.view.sel().add(r)
接下来,安装dacap写的Shrink-Whitespaces插件:
https://github.com/dacap/sublime-shrink-whitespaces.
然后,创建这个宏。将空格缩小两 (2) 次处理存在制表符或制表符+空格的情况。
[
{
"args": null,
"command": "expand"
},
{
"args": null,
"command": "right_delete"
},
{
"args": null,
"command": "shrink_whitespaces"
},
{
"args": null,
"command": "shrink_whitespaces"
},
{
"args":
{
"characters": " "
},
"command": "insert"
}
]
解决方案 #2 -- Sublime Text 2:
安装:https://github.com/bits/ExpandSelectionToWhitespace-SublimeText
创建一个宏并将其绑定到您最喜欢的键盘快捷键:
[
{
"args": null,
"command": "expand_selection_to_whitespace"
},
{
"args":
{
"by": "wordends",
"extend": true,
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "words",
"extend": true,
"forward": false
},
"command": "move"
},
{
"args": null,
"command": "left_delete"
}
]
解决方案#1——Emacs——定义两个函数,并创建一个宏:
(fset 'lawlist-kill-word [?\C-= kp-delete ?\C-+])
(global-set-key (kbd "C-=") 'lawlist-mark-word)
(global-set-key (kbd "C-+") 'delete-horizontal-space-forward)
(defun lawlist-mark-word ()
"Mark the entire symbol around or in front of point."
(interactive)
(let ((symbol-regexp "\\s_\\|\\sw"))
(when (or (looking-at symbol-regexp)
(looking-back symbol-regexp))
(skip-syntax-forward "_w")
(set-mark (point))
(while (looking-back symbol-regexp)
(backward-char)))))
(defun delete-horizontal-space-forward () ; adapted from `delete-horizontal-space'
"*Delete all spaces and tabs after point."
(interactive "*")
(delete-region (point) (progn (skip-chars-forward " \t") (point))))