在Emacs中,如何一次编辑多个点?

时间:2022-10-19 20:37:40

There's two variations. I think you can select a rectangle and add stuff to the beginning and end of all lines.

有两个变化。我认为你可以选择一个矩形然后在所有的线的开头和结尾添加一些东西。

I'd also like to know if it's possible to select multiple points that are on different offsets to where you edit all the points at once. I think Yasnippet provides something similar, but only when you use a predefined template. Something like this.

我还想知道是否有可能选择多个点,这些点在不同的偏移量上同时编辑所有的点。我认为Yasnippet提供了类似的功能,但是只有当您使用预定义的模板时。是这样的。

<div class="">
<a class="">

where i can mark a point on both class things and typing will edit both class attributes. Is it possible?

我可以在两个类上标记一个点,输入将编辑两个类属性。是可能的吗?

2 个解决方案

#1


10  

Emacs Rocks! provides mark-multiple, which does what you want.

Emacs岩石!提供mark-倍数,这是您想要的。

#2


3  

In addition to Juancho's answer, I've used Steve Yegge's multi-select for your purpose. Example usage (the first example will provide what I think you want):

除了Juancho的回答之外,我还使用了Steve Yegge的multi-select作为你的目标。示例用法(第一个示例将提供我认为您需要的内容):

 C-u C-M-m w foo <RET> <RET>
  - inserts/prepends "foo" to every multi-selection (you can also append or replace text)

 C-u -1 C-M-m r <pre>\(\w+\).+\s-+\(.+\)</pre>
  - selects first and last word of the contents every <pre> tag
    (provided the contents don't span multiple lines)

 C-M-m x M-x upcase-region
  - converts all multi-selections in buffer to uppercase

 C-u M-w C-q C-j --- C-q C-j <RET>
  - saves all multi-selections to kill-ring as a single item,
    with selections separated by "---" on a line by itself

#1


10  

Emacs Rocks! provides mark-multiple, which does what you want.

Emacs岩石!提供mark-倍数,这是您想要的。

#2


3  

In addition to Juancho's answer, I've used Steve Yegge's multi-select for your purpose. Example usage (the first example will provide what I think you want):

除了Juancho的回答之外,我还使用了Steve Yegge的multi-select作为你的目标。示例用法(第一个示例将提供我认为您需要的内容):

 C-u C-M-m w foo <RET> <RET>
  - inserts/prepends "foo" to every multi-selection (you can also append or replace text)

 C-u -1 C-M-m r <pre>\(\w+\).+\s-+\(.+\)</pre>
  - selects first and last word of the contents every <pre> tag
    (provided the contents don't span multiple lines)

 C-M-m x M-x upcase-region
  - converts all multi-selections in buffer to uppercase

 C-u M-w C-q C-j --- C-q C-j <RET>
  - saves all multi-selections to kill-ring as a single item,
    with selections separated by "---" on a line by itself