gpt4 book ai didi

emacs - 有没有办法复制整行直到 Emacs 中的停止字符?

转载 作者:行者123 更新时间:2023-12-04 16:49:30 26 4
gpt4 key购买 nike

今天我在VI中看到了一个简洁的复制功能,你可以复制一整行直到一个停止字符。

例如if( copy == this );
使用 VI,他可以复制括号内的所有内容。我想知道你是否也可以用 emacs 做到这一点? (不使用 ctrl+space 并手动标记我想杀死的内容)

最佳答案

尝试

M-z CHAR

通过下一次出现 CHAR 来杀死文本.又名 M-x zap-to-char。感兴趣的可能是 Other Kill Commands 的文档。 .

编辑添加:根据要求,这里是 zap-to-before-char ,它只是获取了 zap-to-char 的源代码并删除了评论(并更新了文档字符串):
(defun zap-to-before-char (arg char)
"Kill up to and ARGth occurrence of CHAR.
Case is ignored if `case-fold-search' is non-nil in the current buffer.
Goes backward if ARG is negative; error if CHAR not found."
(interactive "p\ncZap to char: ")
;; Avoid "obsolete" warnings for translation-table-for-input.
(with-no-warnings
(if (char-table-p translation-table-for-input)
(setq char (or (aref translation-table-for-input char) char))))
(kill-region (point) (progn
(search-forward (char-to-string char) nil nil arg)
(goto-char (if (> arg 0) (1- (point)) (1+ (point))))
(point))))

关于emacs - 有没有办法复制整行直到 Emacs 中的停止字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3919432/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com