所以我试图在一行的开头删除一些空格,当我按 M-d 时,我最终删除的内容超出了我的需要:
(add-to-list 'load-path
"~/path-to-yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
^ ^ | |__ want to delete to here | |___ Cursor here
我看了好几个地方但是还没能做到Vim的 dw 命令。
例如,Emacs'在words上操作的命令似乎没有。
答案 0 :(得分:3)
其实我刚刚发现:
中号 - \
是否适合我,因为我只需要删除空格。
答案 1 :(得分:1)
有很多不同的解决方案,所以这里有一个:
(defun forward-kill-whitespace-or-word ()
"If `point' is followed by whitespace kill that.
Otherwise call `kill-word'"
(interactive)
(if (looking-at "[ \t\n]")
(let ((pos (point)))
(re-search-forward "[^ \t\n]" nil t)
(backward-char)
(kill-region pos (point)))
(kill-word 1)))
修改强> p应该是pos。
答案 2 :(得分:0)
有几种方法可以理解你想要做什么:
dw
命令我选择解决第3项问题,因为这是我自己想做的事情。
我想要执行的操作等同于以下一系列命令:
这就是我所做的:
宏内容如下所示:
;; kill all characters up to but not including the start of the next word
;; (unlike kill-word, which kills the next word as well)
(fset 'my-delete-to-start-of-word
(lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([67108896 C-right C-left delete] 0 "%d")) arg)))