Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Emacs中,在同一个字符串中如何标记字符串?_Emacs - Fatal编程技术网

在Emacs中,在同一个字符串中如何标记字符串?

在Emacs中,在同一个字符串中如何标记字符串?,emacs,Emacs,假设我有一个输出,其中包含: {“我不知道第三次世界大战会用什么武器,但我知道世界大战会用什么武器 第四次世界大战将是用棍子和石头进行的。”,“幸福的家庭只是 “一个更早的天堂。”,“天堂没有像爱变成恨那样的愤怒, 地狱也不会像一个被蔑视的女人那样愤怒 我的光标在一个字符串中(在单词“战斗”之后): “我不知道第三次世界大战会用什么武器,但我知道世界大战会用什么武器 第四次战争将用棍棒和石头进行。” 我想复制整个字符串。 通常我要做的是,我转到字符串的开头,将一个字符移回“C-M-SPC”,然后

假设我有一个输出,其中包含:

{“我不知道第三次世界大战会用什么武器,但我知道世界大战会用什么武器 第四次世界大战将是用棍子和石头进行的。”,“幸福的家庭只是 “一个更早的天堂。”,“天堂没有像爱变成恨那样的愤怒, 地狱也不会像一个被蔑视的女人那样愤怒

我的光标在一个字符串中(在单词“战斗”之后):

“我不知道第三次世界大战会用什么武器,但我知道世界大战会用什么武器 第四次战争将用棍棒和石头进行。”

我想复制整个字符串。 通常我要做的是,我转到字符串的开头,将一个字符移回“C-M-SPC”,然后按“C-M-SPC”并选择字符串

但我觉得这很麻烦。 有没有办法直接在字符串中选择字符串

如果字符串已转义双引号,也可以选择该字符串,如:

她还说,“学习是大多数成年人在美国谋生的方式。” 21世纪。\“昨天”

在上面的例子中,如果我的光标在“成人”之后,它应该能够正确地选择外部字符串


谢谢。

扩展区域是您的目标。以下是功能:

(defun copy-quoted-string ()
  (interactive)
  "Copies the quoted text, ignoring the escaped quotes"
  (save-excursion
     (search-backward-regexp "[^\\]\"")
     (forward-char)
     (mark-sexp)
     (kill-ring-save (point) (mark))))

;this is for testing
(global-set-key [f2] 'copy-quoted-string)
对于测试,我使用了以下字符串:

"text text", "text \"quoted text\" text"

当我按F2键时,当光标位于“文本”内时,此字符串被复制到剪贴板中。当我处于“文本”中时,此字符串被复制。

我发现了另一种选择: 多亏了韦当

:

;;; Function to mark complete word, and expand to sentence etc.
;;; by Nikolaj Schumacher, 2008-10-20. Released under GPL.
(defun semnav-up (arg)
  (interactive "p")
  (when (nth 3 (syntax-ppss))
    (if (> arg 0)
        (progn
          (skip-syntax-forward "^\"")
          (goto-char (1+ (point)))
          (decf arg))
      (skip-syntax-backward "^\"")
      (goto-char (1- (point)))
      (incf arg)))
  (up-list arg))


;;; by Nikolaj Schumacher, 2008-10-20. Released under GPL.
(defun extend-selection (arg &optional incremental)
  "Select the current word.
Subsequent calls expands the selection to larger semantic unit."
  (interactive (list (prefix-numeric-value current-prefix-arg)
                     (or (and transient-mark-mode mark-active)
                         (eq last-command this-command))))
  (if incremental
      (progn
        (semnav-up (- arg))
        (forward-sexp)
        (mark-sexp -1))
    (if (> arg 1)
        (extend-selection (1- arg) t)
      (if (looking-at "\\=\\(\\s_\\|\\sw\\)*\\_>")
          (goto-char (match-end 0))
        (unless (memq (char-before) '(?\) ?\"))
          (forward-sexp)))
      (mark-sexp -1))))

(global-set-key (kbd "C-=") 'extend-selection)