vim:显示子匹配内容和替换中的未命名寄存器

发布于 2024-12-23 11:39:18 字数 669 浏览 2 评论 0原文

我在命令行中有多个命令,用于在未命名的寄存器 @" 中构建文本字符串。然后我有一个捕获几个原子的替代品。最后,我需要用两个子匹配(\1 和\2) 和@"。

在首次显示子匹配之后,我无法让 @" reg 显示其内容。我可以在显示子匹配之前显示 @" 。例如:

multi-commands | @"=textString | 'a,'bs/(atom1)(atom2)/\1\2 "displays perfectly

或者,

multi-commands | @"=textString | 'a,'bs/(atom1)(atom2)/\=@" "displays 'textString' perfectly

但是,

multi-commands | @"=textString | 'a,'bs/(atom1)(atom2)/\1\2@"
multi-commands | @"=textString | 'a,'bs/(atom1)(atom2)/\1\2\@"
multi-commands | @"=textString | 'a,'bs/(atom1)(atom2)/\1\2\=@"

全部无法显示“textString”的寄存器内容,而是显示“@”'

有人知道这是为什么吗?

I've got multiple commands in a command line that builds a text string in the unnamed register @". Then I have a substitute that captures a couple of atoms. Finally, I need to replace a pattern with the two submatches (\1 and \2) AND the @".

I cannot get the @" reg to display its contents AFTER first displaying the submatches. I can display the @" prior to displaying the submatches. For ex:

multi-commands | @"=textString | 'a,'bs/(atom1)(atom2)/\1\2 "displays perfectly

Or,

multi-commands | @"=textString | 'a,'bs/(atom1)(atom2)/\=@" "displays 'textString' perfectly

But,

multi-commands | @"=textString | 'a,'bs/(atom1)(atom2)/\1\2@"
multi-commands | @"=textString | 'a,'bs/(atom1)(atom2)/\1\2\@"
multi-commands | @"=textString | 'a,'bs/(atom1)(atom2)/\1\2\=@"

All fail to display the register contents of 'textString' and instead show '@"'

Does anyone know why that is?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡淡绿茶香 2024-12-30 11:39:18

这是因为 \= 需要成为替换中的第一项。

您应该使用以下内容:

:'a,'bs/(atom1)(atom2)/\=submatch(1).submatch(2).@"

That's because of \= needs to be first item in a replacement.

You should use the following:

:'a,'bs/(atom1)(atom2)/\=submatch(1).submatch(2).@"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文