【发布时间】:2020-04-27 14:35:41
【问题描述】:
我有:
RT_T_up2 = CubicSpline(z_alot, RT_tab_up2)
RT_T_dw2 = CubicSpline(z_alot, RT_tab_dw2)
RT_T_up3 = CubicSpline(z_alot, RT_tab_up3)
RT_T_dw3 = CubicSpline(z_alot, RT_tab_dw3)
RT_T_up4 = CubicSpline(z_alot, RT_tab_up4)
RT_T_dw4 = CubicSpline(z_alot, RT_tab_dw4)
我想在 up 和 dw 前面加上一个“1”,即得到:
RT_T_up12 = CubicSpline(z_alot, RT_tab_up12)
RT_T_dw12 = CubicSpline(z_alot, RT_tab_dw12)
RT_T_up13 = CubicSpline(z_alot, RT_tab_up13)
RT_T_dw13 = CubicSpline(z_alot, RT_tab_dw13)
RT_T_up14 = CubicSpline(z_alot, RT_tab_up14)
RT_T_dw14 = CubicSpline(z_alot, RT_tab_dw14)
原文是用可视模式选择到vim中的。
我试过了:
:'<,'>s:up\([2-4]\):up1\1:e | s:dw\([2-4]\):dw1\1:e
但它只替换了第一个 up 通过给出:
RT_T_up12 = CubicSpline(z_alot, RT_tab_up2)
RT_T_dw2 = CubicSpline(z_alot, RT_tab_dw2)
RT_T_up13 = CubicSpline(z_alot, RT_tab_up3)
RT_T_dw3 = CubicSpline(z_alot, RT_tab_dw3)
RT_T_up14 = CubicSpline(z_alot, RT_tab_up4)
RT_T_dw4 = CubicSpline(z_alot, RT_tab_dw4)
如何在每个 up 和 dw 模式之后插入“1”?
【问题讨论】:
-
我认为您需要将 g 标志添加到替换中
-
StackOverflow 致力于帮助解决编程代码问题。您的 Q 似乎更适合 Super User 或 Vi and Vim ,但请阅读他们关于主题问题的帮助部分。并且请先阅读Help On-topic 和Help How-to-ask,然后再在此处发布更多问题。祝你好运。
标签: vim sed replace substitution