[TriLUG] Cutting and Pasting In a Terminal Window

Al Koscielny alko at nc.rr.com
Tue Mar 12 09:34:10 EST 2002


Buffers can be used to copy and paste text in vi.  yy will yank the current 
line, p or P to paste it below or above the line the cursor is currently on.  
4yy, for example, will yank 4 lines. In general, y<cursor movement> can be 
used to yank other text areas, such as word (w), paragraph({), or the rest of 
the file(G).  

To avoid counting lines, use the mark place command  m<any letter>, such as 
ma, to mark one end of the text selection. Position the cursor on the other 
end of the selection and yank the text with 
y`<the letter used in the mark command>, such as y`a, then paste it with the 
p or P command.  I find yank lines and yank to a mark to be the most useful. 

The unamed buffer is usually sufficient but you can use up to 26 named 
buffers for a really intricate cut and paste session. To use a named buffer, 
use "<some letter> before using a yank or paste command, such as
"k7yy, to yank 7 lines into the k buffer and "kp, to paste the 7 lines.

Other editors, such as gvim and nedit work much better for cutting and 
pasting with the mouse than vi in a terminal window. On the other hand, the 
keyboard commands are a bit cryptic but can save you from a shoulder 
impingement resulting from constantly reaching for the mouse with an 
unsupported elbow

The two button emulation mode is difficult to use and Shift+Ins will do the 
paste but that's a lot of hand motion.  Linda Mui in X User Tools suggests 
xmodmap -e "pointer = 1 3 2"
to switch the middle and right mouse buttons, then the right button can be 
used to paste with a 2 button mouse.

HTH,
-- 
Al Koscielny
alko at nc.rr.com



More information about the TriLUG mailing list