Emacs:删除表达式之间的空格

Fil*_*evi 5 emacs whitespace elisp clojure key-bindings

在编写Clojure代码时,我经常在最后一个表达式和结束括号之间留下空格.就像是

(defn myfunction
  [arg]
  (do
    (expr1)
    (expr2)|
  ))
Run Code Online (Sandbox Code Playgroud)

哪里| 是光标的位置.Emacs中是否有一个快捷方式来删除(expr2)和最后一个括号之间的空格?目标是结束

(defn myfunction
  [arg]
  (do
    (expr1)
    (expr2)))
Run Code Online (Sandbox Code Playgroud)

nic*_*kie 1

改进@wvxvw上面的评论,您可以将以下内容添加到您的.emacs文件中。然后,C-z m(或您选择的任何其他组合键)将执行您想要的操作。事实上,如果您位于包含 的行的任何一点,它都会起作用(expr1)

(global-set-key "\C-zm" 'join-lines-removing-spaces)
(defun join-lines-removing-spaces ()
  "Join the current line with the next, removing all whitespace at this point."
  (move-end-of-line nil)
  (kill-line)
  (delete-horizontal-space))
Run Code Online (Sandbox Code Playgroud)