m (Reverted edits by 77.91.130.14 (talk | block) to last version by JohnBeckett) |
|||
(18 intermediate revisions by 15 users not shown) | |||
Line 1: | Line 1: | ||
− | {{review}} |
||
{{TipImported |
{{TipImported |
||
|id=312 |
|id=312 |
||
Line 14: | Line 13: | ||
Ever try to cut (or copy) some lines and paste to another place? If you need to count the lines first, then try these to eliminate counting task. |
Ever try to cut (or copy) some lines and paste to another place? If you need to count the lines first, then try these to eliminate counting task. |
||
− | Cut and |
+ | Cut and paste: |
− | # |
+ | #Position the cursor where you want to begin cutting. |
⚫ | |||
− | #Mark it with md |
||
− | # |
+ | #Move the cursor to the end of what you want to cut. |
+ | #Press '''d''' to cut or '''y''' to copy. |
||
− | #Cut it with d'd |
||
− | # |
+ | #Move to where you would like to paste. |
⚫ | |||
− | #Press P. |
||
⚫ | |||
− | Copy and Paste: |
||
− | #Place the cursor at the beginning of the block you want to COPY. |
||
− | #Mark it with my |
||
− | #Go to the end of the block. |
||
− | #Copy it with y'y |
||
− | #Go to the new location that you want to PASTE those text. |
||
− | #Press P. |
||
The name of the mark used is related to the operation (d:delete or y:yank). |
The name of the mark used is related to the operation (d:delete or y:yank). |
||
Line 34: | Line 27: | ||
I found that those mark names requires minimal movement of my finger. |
I found that those mark names requires minimal movement of my finger. |
||
+ | ==Copying and pasting outside the editor buffer== |
||
⚫ | |||
− | Cut and paste: |
||
− | #Position the cursor where you want to begin cutting. |
||
⚫ | |||
− | #Move the cursor to the end of what you want to cut. |
||
− | #Press d. |
||
− | #Move to where you would like to paste. |
||
⚫ | |||
− | |||
⚫ | |||
− | |||
If you want to copy and paste between editor buffers (but not between instances of vim), or if you want to maintain multiple "clipboards" (copy buffers), you can name your buffer by pressing "x (that's a double quote followed by x, where x is the single letter name you choose for your buffer) before the d in step 4, and again before the p in step 6. |
If you want to copy and paste between editor buffers (but not between instances of vim), or if you want to maintain multiple "clipboards" (copy buffers), you can name your buffer by pressing "x (that's a double quote followed by x, where x is the single letter name you choose for your buffer) before the d in step 4, and again before the p in step 6. |
||
+ | ===Windows clipboard=== |
||
If you happen to be using gvim for Windows and want to copy or cut into the Windows clipboard, press Ctrl+Insert in step 4 (to copy) or Shift+Delete to cut. To paste from the Windows clipboard, press Shift+Insert. |
If you happen to be using gvim for Windows and want to copy or cut into the Windows clipboard, press Ctrl+Insert in step 4 (to copy) or Shift+Delete to cut. To paste from the Windows clipboard, press Shift+Insert. |
||
⚫ | |||
⚫ | |||
+ | |||
⚫ | |||
+ | |||
⚫ | |||
+ | |||
+ | ===Different instances=== |
||
How copy and paste between two instances of Vim on different Linux consoles? |
How copy and paste between two instances of Vim on different Linux consoles? |
||
Line 62: | Line 52: | ||
read the dummy file (:r ~/dummy) |
read the dummy file (:r ~/dummy) |
||
+ | ==Increasing the buffer size== |
||
− | ---- |
||
+ | Sometimes you can only copy up to 50 lines. To solve this, increase the buffer limit between multiple files. |
||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
− | ---- |
||
⚫ | |||
− | |||
− | ---- |
||
− | Why can I not copy and paste a block of 200 lines? The yank works fine, but the paste only does about 50. |
||
− | |||
− | ---- |
||
− | same problem with me (50 line limit). I've fixed this before but dont dont remember what the fix was. |
||
− | |||
− | ---- |
||
− | Increase the buffer limit between multiple files. |
||
− | |||
:help 'viminfo' |
:help 'viminfo' |
||
Line 88: | Line 61: | ||
:set viminfo? |
:set viminfo? |
||
:set viminfo='100,<100,s10,h |
:set viminfo='100,<100,s10,h |
||
+ | |||
⚫ | |||
⚫ | |||
+ | |||
⚫ |
Revision as of 18:23, 19 September 2014
created August 13, 2002 · complexity intermediate · author Anis W. Nugroho · version 5.7
Ever try to cut (or copy) some lines and paste to another place? If you need to count the lines first, then try these to eliminate counting task.
Cut and paste:
- Position the cursor where you want to begin cutting.
- Press v (or upper case V if you want to cut whole lines).
- Move the cursor to the end of what you want to cut.
- Press d to cut or y to copy.
- Move to where you would like to paste.
- Press P to paste before the cursor, or p to paste after.
Copy and paste can be performed with the same steps, only pressing y instead of d in step 4.
The name of the mark used is related to the operation (d:delete or y:yank).
I found that those mark names requires minimal movement of my finger.
Copying and pasting outside the editor buffer
If you want to copy and paste between editor buffers (but not between instances of vim), or if you want to maintain multiple "clipboards" (copy buffers), you can name your buffer by pressing "x (that's a double quote followed by x, where x is the single letter name you choose for your buffer) before the d in step 4, and again before the p in step 6.
Windows clipboard
If you happen to be using gvim for Windows and want to copy or cut into the Windows clipboard, press Ctrl+Insert in step 4 (to copy) or Shift+Delete to cut. To paste from the Windows clipboard, press Shift+Insert.
If you want to simulate the Windows way of Cut/Copy/Paste you could add the following line to your initialization file.
source $VIMRUNTIME/mswin.vim
Read :help :behave for other information.
Different instances
How copy and paste between two instances of Vim on different Linux consoles?
After copying text, open a new buffer for a new file:
:e ~/dummy
paste the text to the new buffer
write the new buffer (:w)
switch to the previous buffer (:bp) to release *.swp
now switch to the other console
put the cursor at the desired place
read the dummy file (:r ~/dummy)
Increasing the buffer size
Sometimes you can only copy up to 50 lines. To solve this, increase the buffer limit between multiple files.
:help 'viminfo' ... < Maximum number of lines saved for each register. ... :set viminfo? :set viminfo='100,<100,s10,h
See also: Quick yank and paste}}