为VIM或Emacs中的每个符号选择并插入

2024-05-15 12:05:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图做到这一点Im维姆,但我也为emacs开放。你知道吗

假设我有这样一段代码。你知道吗

test.butter0.(A, b)
test.butter1.(A, b)
test.butter2.(A, b)
test.butter3.(A, b)
test.butter4.(A, b)
test.butter5.(A, b)

现在我按控制键V,选择所有的“.”符号。现在我要按冒号“:”并为每个“.”符号插入冒号。你知道吗

因此,选择然后按一个键,然后将该键插入所选符号或字母的每个位置。如果我也可以从我的文件中复制一个符号或字符串,然后选择所有句点或@sings或所有数字或任何符号的垂直列,然后粘贴它,但为每个选定的符号替换它,那也太棒了。你知道吗

像这样:

test:butter0.(A, b)
test:butter1.(A, b)
test:butter2.(A, b)
test:butter3.(A, b)
test:butter4.(A, b)
test:butter5.(A, b)

或者

test.butter@.(A, b)
test.butter@.(A, b)
test.butter@.(A, b)
test.butter@.(A, b)
test.butter@.(A, b)
test.butter@.(A, b)

有可能吗?如果是,怎么做?如果不可能,为每个符号扩展名编写Select+insert有多难?你知道吗


Tags: 代码test字母符号emacsimbutter冒号
3条回答
  • 如您所述,直观地选择文本块
  • 按“:”
  • s/\./:/g

这是你想要的吗?你知道吗

尝试

:1,5s/[0-5]\.(/\@:(/g


其中1,5=>;开始、结束行号


或者选择文本,然后使用

:'<,'>s/[0-5]\.(/\@:(/g

你可以按“r:”(没有引号)。 它将用冒号字符替换整个块。你知道吗

相关问题 更多 >