On Sat, Nov 12, 2011 at 11:30, Guido Van Hoecke <[email protected]> wrote:
> Hi,
>
> I want to edit a csv file with e.g. following content:
>
> "tag2",2011/10/31,28250,28208,0,0,0.9985
> "tag1",2011/10/31,1591,1583,8,0,1
> "tag2",2011/10/30,15046,15008,0,0,0.9975
> "tag1",2011/10/30,981,975,6,0,1
> "tag2",2011/10/29,13019,12993,0,0,0.998
> "tag1",2011/10/29,401,401,0,0,1
> "tag2",2011/10/28,8687,8674,0,0,0.9985
> "tag1",2011/10/28,1245,1233,12,0,1
> "tag2",2011/10/27,8117,8108,0,0,0.9989
> "tag1",2011/10/27,703,697,6,0,1
> "tag2",2011/10/26,8327,8318,0,0,0.9989
> "tag1",2011/10/26,496,496,0,0,1
> "tag2",2011/10/25,0,0,0,0,0
> "tag1",2011/10/25,973,971,2,0,1
> "tag2",2011/10/24,0,0,0,0,0
> "tag1",2011/10/24,823,823,0,0,1
> "tag2",2011/10/23,0,0,0,0,0
> "tag1",2011/10/23,1938,1936,2,0,1
> "tag2",2011/10/22,0,0,0,0,0
> "tag1",2011/10/22,968,968,0,0,1
> "tag2",2011/10/21,0,0,0,0,0
> "tag1",2011/10/21,526,526,0,0,1
> "tag2",2011/10/20,0,0,0,0,0
> "tag1",2011/10/20,828,828,0,0,1
> "tag2",2011/10/19,0,0,0,0,0
> "tag1",2011/10/19,1079,1079,0,0,1
> "tag2",2011/10/18,0,0,0,0,0
> "tag1",2011/10/18,850,849,1,0,1
> "tag2",2011/10/17,0,0,0,0,0
> "tag1",2011/10/17,2056,2056,0,0,1
> "tag2",2011/10/16,0,0,0,0,0
> "tag1",2011/10/16,1545,1542,3,0,1
> "tag2",2011/10/15,0,0,0,0,0
> "tag1",2011/10/15,1801,1783,18,0,1
> "tag2",2011/10/14,0,0,0,0,0
> "tag1",2011/10/14,1651,1644,5,0,0.9988
> "tag2",2011/10/13,0,0,0,0,0
> "tag1",2011/10/13,1785,1785,0,0,1
> "tag2",2011/10/12,0,0,0,0,0
> "tag1",2011/10/12,2071,2071,0,0,1
>
> I want to get rid of all lines ending on 0,0,0,0,0
> I want to replace all ',' by ';'
> I want to replace all '.' by ','
>
> With three individual commands, all is ok:
>
> :%g/0,0,0,0,0/d
> :%s/,/;/g
> :%s/\./,/g
>
> The end result is (as expected):
> "tag2";2011/10/31;28250;28208;0;0;0,9985
> "tag1";2011/10/31;1591;1583;8;0;1
> "tag2";2011/10/30;15046;15008;0;0;0,9975
> "tag1";2011/10/30;981;975;6;0;1
> "tag2";2011/10/29;13019;12993;0;0;0,998
> "tag1";2011/10/29;401;401;0;0;1
> "tag2";2011/10/28;8687;8674;0;0;0,9985
> "tag1";2011/10/28;1245;1233;12;0;1
> "tag2";2011/10/27;8117;8108;0;0;0,9989
> "tag1";2011/10/27;703;697;6;0;1
> "tag2";2011/10/26;8327;8318;0;0;0,9989
> "tag1";2011/10/26;496;496;0;0;1
> "tag1";2011/10/25;973;971;2;0;1
> "tag1";2011/10/24;823;823;0;0;1
> "tag1";2011/10/23;1938;1936;2;0;1
> "tag1";2011/10/22;968;968;0;0;1
> "tag1";2011/10/21;526;526;0;0;1
> "tag1";2011/10/20;828;828;0;0;1
> "tag1";2011/10/19;1079;1079;0;0;1
> "tag1";2011/10/18;850;849;1;0;1
> "tag1";2011/10/17;2056;2056;0;0;1
> "tag1";2011/10/16;1545;1542;3;0;1
> "tag1";2011/10/15;1801;1783;18;0;1
> "tag1";2011/10/14;1651;1644;5;0;0,9988
> "tag1";2011/10/13;1785;1785;0;0;1
> "tag1";2011/10/12;2071;2071;0;0;1
>
> But I want to combine these three operations in one command:
> :%g/0,0,0,0,0/d|%s/,/;/g|%s/\./,/g
> but this gives following result:
> "tag2";2011/10/31;28250;28208;0;0;0;9985
> "tag1";2011/10/31;1591;1583;8;0;1
> "tag2";2011/10/30;15046;15008;0;0;0;9975
> "tag1";2011/10/30;981;975;6;0;1
> "tag2";2011/10/29;13019;12993;0;0;0;998
> "tag1";2011/10/29;401;401;0;0;1
> "tag2";2011/10/28;8687;8674;0;0;0;9985
> "tag1";2011/10/28;1245;1233;12;0;1
> "tag2";2011/10/27;8117;8108;0;0;0;9989
> "tag1";2011/10/27;703;697;6;0;1
> "tag2";2011/10/26;8327;8318;0;0;0;9989
> "tag1";2011/10/26;496;496;0;0;1
> "tag1";2011/10/25;973;971;2;0;1
> "tag1";2011/10/24;823;823;0;0;1
> "tag1";2011/10/23;1938;1936;2;0;1
> "tag1";2011/10/22;968;968;0;0;1
> "tag1";2011/10/21;526;526;0;0;1
> "tag1";2011/10/20;828;828;0;0;1
> "tag1";2011/10/19;1079;1079;0;0;1
> "tag1";2011/10/18;850;849;1;0;1
> "tag1";2011/10/17;2056;2056;0;0;1
> "tag1";2011/10/16;1545;1542;3;0;1
> "tag1";2011/10/15;1801;1783;18;0;1
> "tag1";2011/10/14;1651;1644;5;0;0;9988
> "tag1";2011/10/13;1785;1785;0;0;1
> "tag1";2011/10/12;2071;2071;0;0;1
>
> Note that all 0.99 get changed into 0;99 rather than 0,99
>
> Is this an error or do I hit some limitation in combining commands?
>
> I have  hlsearch on, and at the end of this combined command all '.' 
> characters
> are highlighted when undoing the change. So the last thing searched was indeed
> '.' and I do not understand why it seems to be replaced with ';'
> rather than ','
>
> Please advise.

Note that this also happens when starting vim with -u NONE

My GVim version is:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 27 2011 19:46:24)
MacOS X (unix) version
Included patches: 1-260
Compiled by Bjorn Winckler <[email protected]>

Kind Regards,

Guido.

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to