Re: vim | reformatting question (fwd)
Sorry for my personal response to you Tony!! -- Forwarded message -- Date: Wed, 13 Sep 2006 10:55:22 -0600 (MDT) From: <[EMAIL PROTECTED]> To: A.J.Mechelynck <[EMAIL PROTECTED]> Subject: Re: vim | reformatting question I guess I'll take a stab at it. Assuming that the lines you are interested in joining are seperated from the rest of your file by a blank line on each side.. vip:normal 3gJ -dan
Re: vim | reformatting question
Nikolaos A. Patsopoulos wrote: Hi, I'm trying to fix a file in the following format : 5,329; 1999; Univ Washington; 695; 2001; NHLBI; 684; 1998; Stanford Univ; 3,537; 1998; La Jolla Inst Allergy & Immunol; 3,333; 1996; BRIGHAM & WOMENS HOSP; 2,967; 1998; Northwestern Univ; 2,936; 2002; NHLBI; 2,695; 1996; ST JUDE CHILDRENS HOSP; 2,581; 1998; Merck Res Labs; into this: 5,329;1999; Univ Washington; 695;2001;NHLBI; 684;1998; Stanford Univ; 3,537;1998;La Jolla Inst Allergy & Immunol; 3,333;1996; BRIGHAM & WOMENS HOSP; etc... I came up with this but sth is missing... :%s/\(^\d,\d\d\d;$\|^\d\d\d;$\)\(^\d\d\d\d;$\)\(^\D\+;$\)/\1\2\3 What about (untested) :%g/\d;$/normal gJ i.e. join with the next line any line ending in a digit followed by a semicolon, and don't insert or remove any spaces. Best regards, Tony.
Re: vim | reformatting question
Max Dyckhoff wrote: It seems like you are just trying to join groups of three lines, which you can do very easily using this following command: :g/./j!3 Hope that helps! Max -Original Message- From: Nikolaos A. Patsopoulos [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 13, 2006 8:48 AM To: vim@vim.org Subject: vim | reformatting question Hi, I'm trying to fix a file in the following format : 5,329; 1999; Univ Washington; 695; 2001; NHLBI; 684; 1998; Stanford Univ; 3,537; 1998; La Jolla Inst Allergy & Immunol; 3,333; 1996; BRIGHAM & WOMENS HOSP; 2,967; 1998; Northwestern Univ; 2,936; 2002; NHLBI; 2,695; 1996; ST JUDE CHILDRENS HOSP; 2,581; 1998; Merck Res Labs; into this: 5,329;1999; Univ Washington; 695;2001;NHLBI; 684;1998; Stanford Univ; 3,537;1998;La Jolla Inst Allergy & Immunol; 3,333;1996; BRIGHAM & WOMENS HOSP; etc... I came up with this but sth is missing... :%s/\(^\d,\d\d\d;$\|^\d\d\d;$\)\(^\d\d\d\d;$\)\(^\D\+;$\)/\1\2\3 Your code and Tim's do exactly what I want to do. Thanks! -- Nikolaos A. Patsopoulos, MD Department of Hygiene and Epidemiology University of Ioannina School of Medicine University Campus Ioannina 45110 Greece Tel: (+30) 26510-97804 mobile: +30 6972882016 Fax: (+30) 26510-97867 (care of Nikolaos A. Patsopoulos) e-mail: [EMAIL PROTECTED]
RE: vim | reformatting question
It seems like you are just trying to join groups of three lines, which you can do very easily using this following command: :g/./j!3 Hope that helps! Max > -Original Message- > From: Nikolaos A. Patsopoulos [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 13, 2006 8:48 AM > To: vim@vim.org > Subject: vim | reformatting question > > Hi, > > I'm trying to fix a file in the following format : > > 5,329; > 1999; > Univ Washington; > 695; > 2001; > NHLBI; > 684; > 1998; > Stanford Univ; > 3,537; > 1998; > La Jolla Inst Allergy & Immunol; > 3,333; > 1996; > BRIGHAM & WOMENS HOSP; > 2,967; > 1998; > Northwestern Univ; > 2,936; > 2002; > NHLBI; > 2,695; > 1996; > ST JUDE CHILDRENS HOSP; > 2,581; > 1998; > Merck Res Labs; > > into this: > > 5,329;1999; Univ Washington; > 695;2001;NHLBI; > 684;1998; Stanford Univ; > 3,537;1998;La Jolla Inst Allergy & Immunol; > 3,333;1996; BRIGHAM & WOMENS HOSP; > etc... > > I came up with this but sth is missing... > > :%s/\(^\d,\d\d\d;$\|^\d\d\d;$\)\(^\d\d\d\d;$\)\(^\D\+;$\)/\1\2\3
Re: vim | reformatting question
I'm trying to fix a file in the following format : 5,329; 1999; Univ Washington; 695; 2001; NHLBI; 684; 1998; Stanford Univ; 3,537; 1998; La Jolla Inst Allergy & Immunol; 3,333; 1996; BRIGHAM & WOMENS HOSP; 2,967; 1998; Northwestern Univ; 2,936; 2002; NHLBI; 2,695; 1996; ST JUDE CHILDRENS HOSP; 2,581; 1998; Merck Res Labs; into this: 5,329;1999; Univ Washington; 695;2001;NHLBI; 684;1998; Stanford Univ; 3,537;1998;La Jolla Inst Allergy & Immunol; 3,333;1996; BRIGHAM & WOMENS HOSP; etc... Do I understand that you're just joining groups of three lines? :g/^/,+2j! will do the trick, if that's the case...If not, your regexp could be tweaked, so let me know and I'll tweak it too. however, given your examples, the above command seems to do what you want. -tim