Wednesday, May 9, 2007

How to Copy and Paste in Linux and Windows

This is a very simple topic, but sometimes little tips can save you a lot of time.

Windows & Linux

First select the text, or item, or location to paste to:
Copy = Ctrl-c, or From the "Edit" menu, select "Copy"
Cut = Ctrl-x, or From the "Edit" menu, select "Cut"
Paste = Ctrl-v, or From the "Edit" menu, select "Paste"

You can copy and paste text, graphics, files, etc. In Windows, you can copy and paste files within Windows Explorer, or you can drag and drop them.

Linux

All of the above, plus:

Copy = Select text with the mouse
Paste = Click the middle mouse button

vi

If you want to copy and paste in vi, that's another topic. To copy a line in vi, type yy (yank line), and then p (paste after), or P (paste before). To copy a word, use yw (yank word). To copy five lines -- 5 yy, or five words -- 5 yw, or to paste something five times 5p.
Here are some good tips on vi http://www.vim.org/tips/tip.php?tip_id=312 .

By the way, vi is available for Windows, and is free to download and use -- http://www.vim.org. Vim is excellent for looking at and editing HTML or other code, because it has color coding and syntax highlighting.

Copy and Paste Between Linux and Windows

If you want two have monitors on your desk, you can share the keybord and mouse using an open source program called synergy. http://synergy2.sourceforge.net

Synergy lets you easily share a single mouse and keyboard between multiple computers with different operating systems without special hardware. It's intended for users with multiple computers on their desk since each system uses its own monitor(s). Just move the mouse off the edge of a screen to move to another screen; keyboard and mouse input is then redirected to the other screen. Synergy also lets you cut and paste between systems and it makes screen savers activate/deactivate in concert.

Cygwin and Windows Command Prompts (topic added Dec, 2007)

Another question people may have is how to copy text from a cygwin window, Windows command prompt, and ssh session such as putty. The typical Windows method of copy / paste is to either use ctrl-ins (copy) and shift-ins (paste), or ctrl-c (copy), ctrl-v (paste), but in command prompts it is different. Here is the trick:

1) Select the upper left corner of the command prompt window (left or right-click)
2) From the menu, select Edit
3) From the submenu, select Mark
4) Then use the mouse to highlight the area to be copied from the command prompt window
5) Press Enter to copy it to the clipboard
6) Now go to another application and paste it.
Note: to paste text into a command prompt, use the same upper left menu, and select Edit, Paste

No comments: