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 @".
我在命令行中有多个命令,在未命名寄存器@中构建一个文本字符串。然后我有一个能捕获几个原子的替代品。最后,我需要用两个子匹配(\1和\2)和@”替换一个模式。
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:
在第一次显示子匹配后,我无法让@" reg显示它的内容。我可以在显示子匹配之前显示@"。为例:
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 '@"'
都没有显示'textString'的寄存器内容,而是显示'@"
Does anyone know why that is?
有人知道为什么吗?
1 个解决方案
#1
3
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).@"
#1
3
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).@"