python - Find every third value and insert cr or newline in VIM -


so have several large datasets need make more readable , i'm having go in , move each 3rd value , insert newline. i've tried several things in vim work, none seem return value i'm looking for. here's of data:

(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) 

what need make instead:

(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) 

i used on selection try , move 3rd value down, duplicated entire thing , moved entire line down:

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

i tried removing 1 make work, didn't work either. there way can capture 3rd value , insert carriage return or newline make work? thanks.

edit---

i apologize mis-communicating part of problem: data @ top on 1 line, not several lines. looks this:

(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 

explanation:

  • :g/./{cmd} run {cmd} on every line
  • norm! execute following string normal mode commands
  • 2wi^m move 2 words insert return
  • ^m accomplished pressing <c-v><cr> or <c-q><cr>.

it tempting %norm! 2wi^m, fail messes lines being worked on.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -