我正在尝试尽可能避免使用 elisp。我认为我能够在 Elisp 中实现我的问题的解决方案,但这不是我想要的。
I am looking for the nth occurence of a string in a buffer.
For instance looking after the 4th occurence of foo
, I've tried C-u C-s foo
. But C-s
does not interpret prefixes.
Emacs 中是否有一个简单/优雅的按键序列来执行该工作?
search-forward
是一个简单的函数,用于搜索字符串的下一个匹配项。它还接受可选的COUNT
寻找下一个参数COUNT
连续发生。
不幸的是,您不能使用前缀参数调用它,因为它会查询输入。
你已经猜到了答案:拼凑一些 elisp。
此函数向您查询字符串和计数并执行搜索:
(defun search-forward-count (string count)
(interactive "sString: \nnCount: ")
(re-search-forward string nil nil count))
此函数向您查询字符串并使用前缀参数作为其计数:
(defun search-forward-prefix (count string)
(interactive "p\nsString: ")
(re-search-forward string nil nil count))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)