替换所有缓冲区emacs上的字符串



我使用M-x replace-stringM-%来替换emacs缓冲区中的字符串。

它们的问题是,它们只替换从缓冲区的当前位置向前的字符串。我怎么能把它压得到处都是?

我不想做M-<到达开始然后再做。

看起来这是不可能交互的。所以让我们一起做一些Elisp。

(defun my-replace-allbuffer (str-orig str-replace)
     (interactive "sString ? nsReplace with ? ")
     (replace-string str-orig str-replace nil (point-min) (point-max))
     )

并将函数绑定到您首选的密钥绑定。

replace-stringC-h f replace-string RET)的文档告诉我们,它可以使用可选参数开始和结束替换。

更多文档:

  • http://ergoemacs.org/emacs/elisp_basics.html
  • http://wikemacs.org/wiki/Category:Emacs_Lisp所以http://wikemacs.org/wiki/Emacs_Lisp_Cheat_Sheet

最新更新