加一个定位范围就行了
:%s/^\[\zs\(\d\+\)\ze\]/\=submatch(1)+5/
【 在 lee906 的大作中提到: 】
: 标 题: [求助]请教一个数据运算后替换的问题
: 发信站: 水木社区 (Sat Nov 11 12:27:13 2023), 站内
:
: 想修改有一大段章节的参考方献的序号,一直没搞定,特来请教。
:
: 把原来的
:
:
:
哈哈哈[11]呵呵呵[12][13]啊啊啊[14-15]。。。
:
: [11] Office of the Under Secretary of Defense for Research and Engineering.Modular open systems approach(MOSA) reference frameworks in defense acquisition programs, 20301-3030[R].Washington D.C,USA:DoD,2020,5.
: [12] GULDEN T R,LAMB J,HAGEN J,et al.Modeling rapidly composable,heterogeneous,and fractionated forces,978-1- 9774-0447-3[R].Santa Monica,California,USA:RAND Corporation,2021.
: [13] GRANA J,LAMB J,NICHOLAS A.O’Donoughue.Findings on mosaic warfare from a colonel blotto game,978-1-9774- 0490-9[R].Santa Monica,California,USA:RAND Corpo ration,2021.
: [14] Nicholas A.O’Donoughue,Samantha Mcbirney,Brian Per- sons.Distributed kill chains,978-1-9774-0613-2[R]. Santa Monica,California,USA:RAND Corporation,2021.
: [15] Nicholas A.O’Donoughue,Samantha Mcbirney,Brian Per- sons.Distributed kill chains,978-1-9774-0613-2[R]. Santa Monica,California,USA:RAND Corporation,2021.:
: 中所有的参考文献序号做平移(加/减一个固定数值),如所有参考文献序号替换成原来序号+5。变成
:
:
哈哈哈[16]呵呵呵[17][18]啊啊啊[19-20]。。。
:
: [16] Office of the Under Secretary of Defense for Research and Engineering.Modular open systems approach(MOSA) reference frameworks in defense acquisition programs, 20301-3030[R].Washington D.C,USA:DoD,2020,5.
: [17] GULDEN T R,LAMB J,HAGEN J,et al.Modeling rapidly composable,heterogeneous,and fractionated forces,978-1- 9774-0447-3[R].Santa Monica,California,USA:RAND Corporation,2021.
: [18] GRANA J,LAMB J,NICHOLAS A.O’Donoughue.Findings on mosaic warfare from a colonel blotto game,978-1-9774- 0490-9[R].Santa Monica,California,USA:RAND Corpo ration,2021.
: [19] Nicholas A.O’Donoughue,Samantha Mcbirney,Brian Per- sons.Distributed kill chains,978-1-9774-0613-2[R]. Santa Monica,California,USA:RAND Corporation,2021.
: [20] Nicholas A.O’Donoughue,Samantha Mcbirney,Brian Per- sons.Distributed kill chains,978-1-9774-0613-2[R]. Santa Monica,California,USA:RAND Corporation,2021.:
:
: 网上搜了一下,应该用submatch。
: 但使用
: :%s/\[\(\d\+\)\]/\=submatch(1)+5]/g
: 会导致前面的“[”丢失。
:
: 使用
: :%s/\[\(\d\+\)\]/[\=submatch(1)+5]/g
: 或
: :%s/\[\(\d\+\)\]/\=[submatch(1)+5]/g
: submatch又不起作用。
:
: 想请教一下这种情况应该如何使用替换命令?
: PS:[14-15]这种情形比较少,我可以手动改,但单个引用的太多了。
:
: 谢谢!
:
:
: --
: ※ 修改:·lee906 于 Nov 11 12:29:42 2023 修改本文·[FROM: 49.94.182.*]
: ※ 来源:·水木社区
http://www.mysmth.net·[FROM: 49.94.182.*]
--
修改:lee906 FROM 49.94.182.*
FROM 113.89.10.*