Re: VI(M) - Changing Merging 2 lines?
On Mon, Sep 01, 2003, Subba Rao wrote about Re: VI(M) - Changing Merging 2 lines?: One other question is, how can I find white space (non-printable) characters in a text file. The records file was created from PDF to text with the help of pdftotext. I don't what characters are in this file, but when I try to import it into an application, the data gets mangled. The file opens fine in any of the spreadsheets. I want to see the characters in the file (not \n or SPACE etc). Whitespace and non-printable characters aren't the same thing, obviously. I'm assuming that you want to see non-printable characters (control characters and non-ASCII characters). One thing you can use is cat -v, as in cat -vE file | less This will show you control characters as ^A, non-ascii characters as M-A, and line ends as $ (this is useful for seeing spaces in the end of the line). 'less file' might also be enough, depending on what you need. If you want to see the character codes of all the characters in your file, you can also use od -c file. -- Nadav Har'El| Tuesday, Sep 2 2003, 5 Elul 5763 [EMAIL PROTECTED] |- Phone: +972-53-245868, ICQ 13349191 |As far as we know, our computer has never http://nadav.harel.org.il |had an undetected error. = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: VI(M) - Changing Merging 2 lines?
Subba Rao wrote: Hello, I have a large text file where 2 lines (fields) form a record. Now I want to merge the 2 lines into one line seperated by a comma. Line1 Line2 The fields should be seperated by a comma. Line1,Line2 How can I define a keystroke that will, add a comma at the end of Line1 perform a JOIN of Line1 and Line2 move the cursor to the next record? Any help appreciated. Thank you in advance. :g!/,/s/\n/,/ this will merge any two lines that the first does not hold a ',' character, so if the file does not include ',' to starts with - every two lines will be merged cheers, erez. = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: VI(M) - Changing Merging 2 lines?
On Mon, Sep 01, 2003 at 11:31:34AM -0400, Subba Rao wrote: Hello, I have a large text file where 2 lines (fields) form a record. Now I want to merge the 2 lines into one line seperated by a comma. Line1 Line2 The fields should be seperated by a comma. Line1,Line2 How can I define a keystroke that will, add a comma at the end of Line1 perform a JOIN of Line1 and Line2 move the cursor to the next record? map key A,^[Jj (^[ is Esc. To type it, press Ctrl-V Esc). If the pairs are not consecutive, but the first matches some regexp, you can replace the last 'j' with '/regexp^M' (^M is Enter). -- Didi Any help appreciated. Thank you in advance. -- Subba Rao [EMAIL PROTECTED] -- Old American Wild West saying: God created men but Colt made them equal. Today: Linus created Linux and Linux made IT companies equal. = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED] = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: VI(M) - Changing Merging 2 lines?
On Mon, Sep 01, 2003 at 11:31:34AM -0400, Subba Rao wrote: Hello, I have a large text file where 2 lines (fields) form a record. Now I want to merge the 2 lines into one line seperated by a comma. Line1 Line2 The fields should be seperated by a comma. Line1,Line2 s/\n/,/ How can I define a keystroke that will, add a comma at the end of Line1 perform a JOIN of Line1 and Line2 move the cursor to the next record? First answer: :map F3 :s/\n/,/ Second answer: :s/\n/,/ And it will be mapped to . (dot) , as it is the last operation -- Tzafrir Cohen +---+ http://www.technion.ac.il/~tzafrir/ |vim is a mutt's best friend| mailto:[EMAIL PROTECTED] +---+ = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: VI(M) - Changing Merging 2 lines?
On Mon, Sep 01, 2003 at 07:25:52PM +0300, Tzafrir Cohen wrote: On Mon, Sep 01, 2003 at 11:31:34AM -0400, Subba Rao wrote: Hello, I have a large text file where 2 lines (fields) form a record. Now I want to merge the 2 lines into one line seperated by a comma. Line1 Line2 The fields should be seperated by a comma. Line1,Line2 s/\n/,/ How can I define a keystroke that will, add a comma at the end of Line1 perform a JOIN of Line1 and Line2 move the cursor to the next record? First answer: :map F3 :s/\n/,/ You had good intentions, but it won't. You need also to move to the next line (both to satisfy the request and to make it comfortable). Second answer: :s/\n/,/ And it will be mapped to . (dot) , as it is the last operation This won't either. I did not check all vi's in existence, only vim, and its docs say : 'You can repeat the non-Ex commands with the . command.' Which is true. Whoever wants to see some nice black wizardy with vi macros, can look at VIM's source, under runtime/macros (you can also find that in /usr/share/doc/vim/macros on Debian, or somewhere under /usr/share/vim on RedHat). I especially liked maze. -- Didi -- Tzafrir Cohen +---+ http://www.technion.ac.il/~tzafrir/ |vim is a mutt's best friend| mailto:[EMAIL PROTECTED] +---+ = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED] = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: VI(M) - Changing Merging 2 lines?
On 0, Yedidyah Bar-David [EMAIL PROTECTED] wrote: On Mon, Sep 01, 2003 at 11:31:34AM -0400, Subba Rao wrote: Hello, I have a large text file where 2 lines (fields) form a record. Now I want to merge the 2 lines into one line seperated by a comma. Line1 Line2 The fields should be seperated by a comma. Line1,Line2 How can I define a keystroke that will, add a comma at the end of Line1 perform a JOIN of Line1 and Line2 move the cursor to the next record? map key A,^[Jj (^[ is Esc. To type it, press Ctrl-V Esc). If the pairs are not consecutive, but the first matches some regexp, you can replace the last 'j' with '/regexp^M' (^M is Enter). Thank you for replying. I modified the macro a little bit and it works. Thanks for the pointer. One other question is, how can I find white space (non-printable) characters in a text file. The records file was created from PDF to text with the help of pdftotext. I don't what characters are in this file, but when I try to import it into an application, the data gets mangled. The file opens fine in any of the spreadsheets. I want to see the characters in the file (not \n or SPACE etc). Thank you once again. -- Subba Rao [EMAIL PROTECTED] -- Old American Wild West saying: God created men but Colt made them equal. Today: Linus created Linux and Linux made IT companies equal. = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: VI(M) - Changing Merging 2 lines?
On Mon, 1 Sep 2003, Subba Rao wrote: Hello, I have a large text file where 2 lines (fields) form a record.Now I want to merge the 2 lines into one line seperated by a comma. Line1 Line2 The fields should be seperated by a comma. Line1,Line2 How can I define a keystrokethat will, add a comma at the end of Line1 perform a JOIN of Line1 and Line2 move the cursor to the next record? Any help appreciated. if this is a large file - isn't it more appealing to do this with a 2 lines perl/python/whatever script? or does the file contain more data then just the lines you described here? --guy = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]