|
Hello Vimmers,
I have to correct some datafiles, and I need to paste a column in the middle of my text file to replace the older column which contain bad values. How can I do that ? Just to illustrate my question, I would like to paste in Vim a column the same way you would do on a speadsheet that is to say, this should not change the total number of lines... Hope I have been clear enough, thank you by advance for your precious help. Regards, Eddine. |
|
1. Use Ctrl-V and the arrow keys to block select the text that you want
to paste. 2. Yank the text with y. 3. Block select the text that you want to replace. 4. Paste over the selection with the text you copied by pressing p. Of course if the text you copy in is a different number of lines then it won't work properly, but otherwise you should be happy! Max > -----Original Message----- > From: Eddine [mailto:[hidden email]] > Sent: Tuesday, June 20, 2006 9:36 AM > To: Vim Mailing List > Subject: Pasting a vertical selection. > > Hello Vimmers, > > > I have to correct some datafiles, and I need to paste a column in the > middle of my text file to replace the older column which contain bad > values. > > How can I do that ? Just to illustrate my question, I would like to > paste in Vim a column the same way you would do on a speadsheet that > is to say, this should not change the total number of lines... > > Hope I have been clear enough, > thank you by advance for your precious help. > > Regards, > Eddine. |
|
In reply to this post by Eddine-2
> I have to correct some datafiles, and I need to paste a column
> in the middle of my text file to replace the older column > which contain bad values. > > How can I do that ? [cut] > Hope I have been clear enough, Yes, that is fairly clear. Vim supports block-wise pasting. However, last I checked (vim7 might expose this), you can only get a blockwise paste by yanking/deleting a blockwise selection. Thus, you'd open a new window, paste your contents (which I assume are coming from outside Vim), and then use control+V to select the whole lot. Once it has been selected, you can yank/delete it. Then, flip back over to your document and navigate to the column in which you want to put the contents. Simply use p (or P depending on your cursor location relative to where you want the text) and it will put in the block of text vertically as you describe. I don't think it will replace, but rather insert text at the location. However, you can use a similar means (control+V, select, "d") to delete the unwanted text column. This does assume that your document(s) is/are truely column-wise, not tab-delimited or CSV columns. To learn more, you can read up on blockwise-visual selection at :help blockwise-visual -tim |
|
In reply to this post by Max Dyckhoff
Fisrt of all thank you Max for your quick answer.
This solution, doesn't seem to work, when I try to paset with "p" over my selection, instead of replacing with the values of my new column, vim insert it... I have the feeling I should type a command such withc would be a mix of vertical-selction-"R"-and-"p"... 2006/6/20, Max Dyckhoff <[hidden email]>: > 1. Use Ctrl-V and the arrow keys to block select the text that you want > to paste. > 2. Yank the text with y. > 3. Block select the text that you want to replace. > 4. Paste over the selection with the text you copied by pressing p. > > Of course if the text you copy in is a different number of lines then it > won't work properly, but otherwise you should be happy! > > Max |
|
Are you block selecting all the text you want to replace? If you block
select the text you want to replace and then paste over it, everything should work fine... Max > -----Original Message----- > From: Eddine [mailto:[hidden email]] > Sent: Tuesday, June 20, 2006 10:00 AM > To: Vim Mailing List > Cc: Max Dyckhoff > Subject: Re: Pasting a vertical selection. > > Fisrt of all thank you Max for your quick answer. > > This solution, doesn't seem to work, when I try to paset with "p" over > my selection, instead of replacing with the values of my new column, > vim insert it... > I have the feeling I should type a command such withc would be a mix > of vertical-selction-"R"-and-"p"... > > 2006/6/20, Max Dyckhoff <[hidden email]>: > > 1. Use Ctrl-V and the arrow keys to block select the text that you > > to paste. > > 2. Yank the text with y. > > 3. Block select the text that you want to replace. > > 4. Paste over the selection with the text you copied by pressing p. > > > > Of course if the text you copy in is a different number of lines then it > > won't work properly, but otherwise you should be happy! > > > > Max |
|
In reply to this post by Eddine-2
On Tue, 20 Jun 2006 at 11:51am, Tim Chase wrote: > > I have to correct some datafiles, and I need to paste a column > > in the middle of my text file to replace the older column > > which contain bad values. > > > > How can I do that ? > [cut] > > Hope I have been clear enough, > > Yes, that is fairly clear. Vim supports block-wise pasting. > However, last I checked (vim7 might expose this), you can only > get a blockwise paste by yanking/deleting a blockwise selection. FWIW, the setreg() function in 6.3 itself supported the "b" option to set a register with "block" content. You can even set the width of the block. -- HTH, Hari > Thus, you'd open a new window, paste your contents (which I > assume are coming from outside Vim), and then use control+V to > select the whole lot. Once it has been selected, you can > yank/delete it. Then, flip back over to your document and > navigate to the column in which you want to put the contents. > Simply use p (or P depending on your cursor location relative to > where you want the text) and it will put in the block of text > vertically as you describe. I don't think it will replace, but > rather insert text at the location. However, you can use a > similar means (control+V, select, "d") to delete the unwanted > text column. > > This does assume that your document(s) is/are truely column-wise, > not tab-delimited or CSV columns. > > To learn more, you can read up on blockwise-visual selection at > > :help blockwise-visual > > -tim > > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
| Powered by Nabble | Edit this page |
