Copy and paste text with vi or vim
The ability to duplicate text in an editor can be handy. vi and vim have several useful copy and paste commands.
The command 'Y' or 'yy' copies (yanks) one or more lines. To copy one line, two lines, 10 lines, and all lines to the end of the file, respectively:
2Y
10Y
yG
To paste the text contained in the buffer above (uppercase P) or below the current cursor position (lowercase p), respectively:
p
It is also possible to yank text within a line. The following commands yank text from the current cursor position to the end of the word and the end of the line, respectively:
y$
The same commands paste the text within a line. Lower case p pastes after the cursor position and upper case P pastes before.
Paste will also work with deleted text, either lines or parts of lines. Be careful not to execute any other commands prior to pasting as this will empty the buffer.
Also see ...
H3When you want to find all of the files matching a certain filename pattern, a wildcard can be used with the find command/H3PTo find all files ending with .html: br / br /div class="code"find / name \*.html printP br /The character causes the shell to ignore the following c
H3vi and vim have powerful searching capabilities because they bring to bear the richness of regular expressions. /H3PTo search for the next occurence of the text 'maybe' from the current cursor position, type: br / br /div class="code"/maybe<ENTER> br /P br /Search ba
H3You've run netstat an. You see that port TCP/65237 is listening. What program is actually running and holding that port open? Here's how to find out./H3PSometimes you notice odd ports open and listening on your machine. In this day and age, that's often a bad thing. But what do you kil
H3Locate and remove all core files in system using the find command/H3Pdiv class="code"find / name core exec rm &123;&125; \;P br /The find command replaces the {} characters in the command above with the filenames that it finds. You must include the \ immediately before the ;
H3Using the find command, locate all files with zero length/H3PTo find all empty files on the entire system, br / br /div class="code"find / size 0 printP br /To find all empty files from the current directory down, br / br /div class="code"find . size 0 printP
