0

ワープロのバックグラウンドを持つ私が見慣れている動作delete wordは次のとおりです。単語全体と単語の後のすべての空白を削除します。delete_word.pyプラグイン(内/Packages/Default) は、プログラミングのバックグラウンドを持つ人のために空白を保持すると想定しています。

私が見慣れている動作に近づけるには、前の単語の最後にカーソルを置き、次の単語を削除する必要があります (完了時に両方の単語の間に空白が 1 つだけ残るようにします)。

私が最も慣れ親しんでいる動作を実現する、Sublime に既に組み込まれている別のキーボード ショートカットはありますか?

4

1 に答える 1

3

解決策 1 -- 崇高なテキスト 2:

なんらかの理由で、super+d別名はマクロでは機能し ません。プラグインではないようです。そのため、マクロで動作する単語全体を選択するプラグインのサンプルを次に示します。⌘+dfind_under_expandfind_under_expand

 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)

次に、によって書かれた Shrink-Whitespaces プラグインをインストールしますdacap

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 -- 崇高なテキスト 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 -- 2 つの関数を定義し、マクロを作成します。

(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))))
于 2013-03-17T00:22:03.813 に答える