1

对于我的具体问题,我找不到任何合理的答案;我知道如何处理 vim/sed 的替换搜索,但是关于列模式搜索和替换,我们如何处理 vim 中的 csv。即我们在csv中有大量数据:

automotive_bitcount,1,1,0,1,0,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,0,0,1,0,0
automotive_bitcount,1,0,0,1,0,1,0,1,1,1,0,0,0,0,1,1,1,0,1,0,1,0,0,1,0
automotive_bitcount,2,1,0,0,0,0,1,0,1,0,1,1,0,0,0,0,0,0,1,1,1,1,0,1,0
automotive_bitcount,2,0,0,0,1,1,0,0,1,0,0,0,1,1,1,0,0,0,0,1,1,1,1,0,0
automotive_bitcount,2,1,0,0,0,1,1,0,1,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1

代表标题:

APP_NAME, DATASET, COMPILER FLAGS#1,...,COMPILER FLAG#24

这是搜索和替换的语句;我想用相应的“编译器标志选项”(我把它放在这里)替换列中的那些“1”,所以最后我可以有这样的结构,以便将它们传递给编译器:

automotive_bitcount dataset1  -fno-guess-branch-probability -fno-ivopts -fno-tree-loop-optimize -fno-inline-functions  -fno-omit-frame-pointer -falign-jumps -fselective-scheduling  -fno-tree-pre  -fno-move-loop-invariants

仅作记录,24 个编译器标志如下(按它们的顺序):

compilerOptionList= "-funsafe-math-optimizations -fno-guess-branch-probability -fno-ivopts -fno-tree-loop-optimize -fno-inline-functions -funroll-all-loops -fno-omit-frame-pointer -falign-jumps -fselective-scheduling -fno-inline-small-functions -fno-tree-pre ftracer -fno-move-loop-invariants -O2 -fno-tree-ter -fprefethch-loop-arrays -max-unrolled-insns -fno-inline-functions-called-once -fno-cprop-registers -finline-functions -fno-schedule -fno-align-functions -fno-tree-dce -fno-merge-constants"
4

1 回答 1

4

csv.vim - 用于 csv 文件的文件类型插件插件有一个替代命令,其范围为特定列:

:[range]Substitute [column/]pattern/string[/flags]
于 2013-11-07T15:20:21.933 回答