[英]Emacs XML mode: search-and-replace in text (not markup)
Emacs中是否有一種簡單的方法來搜索和替換XML文件中的文本,但是使s&r操作僅作用於文檔文本而不是標記?
例如:
...
There is some text above here
[mark-starts-here]
<some_tag key="value">
text
</some_tag>
[mark-ends-here]
There is some text below here
...
用E
替換e
得到:
...
There is some text above here
[mark-starts-here]
<some_tag key="value">
tExt
</some_tag>
[mark-ends-here]
There is some text below here
...
我不知道xml模式是否具有類似的內置功能,但這是一個簡單的功能:
(defun my-replace-outside-of-tags (regexp replacement)
(while (re-search-forward regexp nil t)
(unless (save-match-data
(looking-at "[^<>]*>"))
(replace-match replacement))))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.