<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Tech-Recipes - Latest Comments in Copy and paste text with vi or vim | UNIX | Tech-Recipes</title><link>http://tech-recipes.disqus.com/</link><description>Cookbook of Tech Tutorials</description><language>en</language><lastBuildDate>Tue, 02 Jun 2009 20:18:58 -0000</lastBuildDate><item><title>Re: Copy and paste text with vi or vim | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/219/copy-and-paste-text-with-vi-or-vim/#comment-10404638</link><description>I realize your post is from 5 months ago from when I'm posting this, saravanan, but for anyone else who may read this:&lt;br&gt;&lt;br&gt;You have several options that I know of--and I'm not even a vim master.  Just for clarity's sake, fileA refers to the file you want to copy *from*, and fileB refers to the file you want to copy *to*.&lt;br&gt;1. You could open fileB, execute the command ":r fileA" (which would copy all of fileA into the open file), and then remove the portions you don't want.&lt;br&gt;2. You could open fileA, execute the command ":split fileB" (which would open fileB to the side of fileA), select the lines you wish to copy from fileA with the combination Shift+V and up/down arrow or j/k, press "y" to yank the lines, switch over to fileB with Ctrl+W Ctrl+W, and then paste the lines with "p".&lt;br&gt;3. Open fileA, select the lines you wish to copy, yank the lines with ""by" (note that's a double-quotation mark in front of the  "b", and that the "b" could be any letter of the alphabet), open fileB, and finally paste the lines with ""bp" (where "b" is the same letter you used to yank).&lt;br&gt;&lt;br&gt;Note that some of these methods may differ, depending on your version of vim.  And by the by, the files don't have to be in the same folder for these options to work; you simply specify the path to the files (i.e., ":split /path/to/fileB").</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Chrissy</dc:creator><pubDate>Tue, 02 Jun 2009 20:18:58 -0000</pubDate></item><item><title>Re: Copy and paste text with vi or vim | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/219/copy-and-paste-text-with-vi-or-vim/#comment-8088100</link><description>thanks for posting this</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">aFree4U</dc:creator><pubDate>Sat, 11 Apr 2009 21:40:54 -0000</pubDate></item><item><title>Re: Copy and paste text with vi or vim | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/219/copy-and-paste-text-with-vi-or-vim/#comment-8075191</link><description>Nice explanation</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ronni</dc:creator><pubDate>Sat, 11 Apr 2009 04:01:35 -0000</pubDate></item><item><title>Re: Copy and paste text with vi or vim | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/219/copy-and-paste-text-with-vi-or-vim/#comment-6372617</link><description>Perfect :)</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Maria</dc:creator><pubDate>Wed, 18 Feb 2009 08:21:56 -0000</pubDate></item><item><title>Re: Copy and paste text with vi or vim | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/219/copy-and-paste-text-with-vi-or-vim/#comment-4328692</link><description>How to copy the portion of a file to another file in the same folder in unix?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">saravanan</dc:creator><pubDate>Thu, 11 Dec 2008 11:06:34 -0000</pubDate></item><item><title>Re: Copy and paste text with vi or vim | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/219/copy-and-paste-text-with-vi-or-vim/#comment-4021281</link><description>Sorry one change...&lt;br&gt;&lt;br&gt;CTRL-V is Visual Block Mode&lt;br&gt;simply use the lowercase "v" to enter visual mode and no need to do the "SHIFT-$" (should be SHIFT-4 or $) as mentioned above. So that process now beomes:&lt;br&gt;&lt;br&gt;go to the line you wish to start yanking/cutting&lt;br&gt;v (enable visual mode)&lt;br&gt;&amp;lt;down arrow&amp;gt; (select the lines you wish to yank/cut) &lt;br&gt;or &lt;br&gt;&amp;lt;right/left arrow&amp;gt; (select characters/words in a line)&lt;br&gt;d (cut lines) or y (yank/copy)&lt;br&gt;&lt;br&gt;now just use 'p' or 'P' as needed to paste below or above cursor!</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">ddreggors</dc:creator><pubDate>Wed, 26 Nov 2008 05:36:56 -0000</pubDate></item><item><title>Re: Copy and paste text with vi or vim | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/219/copy-and-paste-text-with-vi-or-vim/#comment-4021243</link><description>Another nice trick is to use Visual Mode...&lt;br&gt;&lt;br&gt;go to the line you wish to start yanking/cutting&lt;br&gt;CTRL-V (enable visual mode)&lt;br&gt;SHIFT-$ (select to end of line)&lt;br&gt;&amp;lt;down arrow&amp;gt; (select the lines you wish to yank/cut)&lt;br&gt;d (cut lines) or y (yank/copy)&lt;br&gt;&lt;br&gt;now just use 'p' or 'P' as needed to paste below or above cursor!&lt;br&gt;&lt;br&gt;This is the same as fuzzy's except it allows you to "SEE" what you are yanking.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">ddreggors</dc:creator><pubDate>Wed, 26 Nov 2008 05:26:56 -0000</pubDate></item><item><title>Re: Copy and paste text with vi or vim | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/219/copy-and-paste-text-with-vi-or-vim/#comment-3899463</link><description>Nope - just use m to mark the start, with an arbitrary buffer name (so you might type mx).  Move your cursor down to where you want to stop copying, and type y'x (or d'x if you're cutting and pasting).  Then move the cursor to the point where you want to paste, and type p.  Magic.&lt;br&gt;&lt;br&gt;You might find something like this helpful as a reference: &lt;a href="http://www.onlamp.com/pub/a/bsd/2001/10/25/FreeBSD_Basics.html?page=1" rel="nofollow"&gt;http://www.onlamp.com/pub/a/bsd/2001/10/25/Free...&lt;/a&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">fuzzy</dc:creator><pubDate>Wed, 19 Nov 2008 14:27:12 -0000</pubDate></item><item><title>Re: Copy and paste text with vi or vim | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/219/copy-and-paste-text-with-vi-or-vim/#comment-3873949</link><description>Good one.,</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kesavan</dc:creator><pubDate>Tue, 18 Nov 2008 01:54:00 -0000</pubDate></item><item><title>Re: Copy and paste text with vi or vim | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/219/copy-and-paste-text-with-vi-or-vim/#comment-3676995</link><description>I need to yank x amount of lines from the middle of the file.  Am I now suppose to count the amount of lines or what?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">john_doe</dc:creator><pubDate>Tue, 11 Nov 2008 07:11:27 -0000</pubDate></item></channel></rss>