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

sta*_*orn 5 emacs

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

例如 if( copy == this );

使用VI,他可以复制括号内的所有内容.我想知道你是否可以用emacs做到这一点?(不使用ctrl + space并手动标记我要杀死的内容)

Tre*_*son 13

尝试

M-z CHAR
Run Code Online (Sandbox Code Playgroud)

这会在下一次出现时杀死文本CHAR.阿卡M-x zap-to-char.有趣的可能是其他杀戮命令的文档.

编辑添加:根据请求,这里是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))))
Run Code Online (Sandbox Code Playgroud)