python – 查找每个第三个值并在VIM中插入cr或换行符

所以我有几个大型数据集,我需要使其更具可读性,目前我必须进入并移动到每个第3个值并插入换行符.我已经在VIM中尝试了几个方法来实现这一点,但似乎没有一个能够返回我正在寻找的价值.这是我的一些数据:

(0.96260310749184663, 4.3830008206495812, 0.84922658632317849),
(0.96260310749184663, 5.0000002088986637, 1.049701855818201),
(0.96260310749184697, 5.6169993576359696, 0.8492264385213405),
(0.96260310749184719, 5.9983257940402384, 0.32437568665165911),
(0.96260310749184719, 5.9983258053918069, -0.32437572732698844),
(0.96260310749184719, 5.6169994358349786, -0.84922691097323821),
(0.96260310749184697, 5.0000000093711492, -1.0497019267383632)

我需要做的是让它看起来像这样:

(0.96260310749184663, 4.3830008206495812, 
 0.84922658632317849),
(0.96260310749184663, 5.0000002088986637, 
 1.049701855818201),
(0.96260310749184697, 5.6169993576359696, 
 0.8492264385213405),
(0.96260310749184719, 5.9983257940402384, 
 0.32437568665165911),
(0.96260310749184719, 5.9983258053918069, 
 -0.32437572732698844),
(0.96260310749184719, 5.6169994358349786, 
 -0.84922691097323821),
(0.96260310749184697, 5.0000000093711492, 
 -1.0497019267383632)

我在选择中使用它来尝试让它将第三个值向下移动,但它复制了整个事物,然后将整行移动:

:'<,'>s/\([-[0-9.]\+,\s[-[0-9.]\+,\)/\1\r&/g

我也尝试删除1以使其工作,但这也不起作用.那么有什么方法可以捕获第三个值并插入回车符或换行符来使其工作?谢谢.

编辑 – –

我为错误沟通我的部分问题而道歉:顶部的数据全部在一行,而不是几行.它看起来像这样:

(0.31852533878680489, 0.10352149350126813, -0.0046069731261429991), (0.31852526554320226, -0.103521543762028, -0.0046069731261429991), (0.19682845687859715, -0.27102285045297636, -0.004606973126142444), (-8.1184530326649769e-05, -0.33500267513407755, -0.0046069731261416669), (-0.19699089317458821, -0.27102292369657782, -0.0046069731261408897), (-0.31868770183919259, -0.10352150714022559, -0.0046069731261403346), (-0.31868770183919221, 0.10352156674487166, -0.0046069731261403346),
:g/./norm! 2Wi^M

说明:

>:g /./ {cmd}将在每一行上运行{cmd}
>规范!将执行以下字符串作为普通模式命令
> 2Wi ^ M移动2个字然后插入一个返回
> ^ M通过按下< c-v>< cr>来完成.或< c-q>< cr>.

做%规范非常诱人! 2Wi ^ M,但这会失败,因为它弄乱了正在处理的线条.

相关文章
相关标签/搜索