Vim Tips Wiki
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 15: Line 15:
 
==Cut and paste==
 
==Cut and paste==
 
Cut the line that you want to move by typing <code>dd</code>, or visually select some lines (press <code>V</code> then move the cursor) and type <code>d</code> to cut the selected block.
 
Cut the line that you want to move by typing <code>dd</code>, or visually select some lines (press <code>V</code> then move the cursor) and type <code>d</code> to cut the selected block.
 
Then move the cursor, and paste the text at the new position (press <code>p</code> to paste after the line with the cursor, or <code>P</code> to paste before).
 
   
 
You can cut several lines, or blocks of text, by appending to a register using an uppercase letter, for example:
 
You can cut several lines, or blocks of text, by appending to a register using an uppercase letter, for example:
  +
*
*Move to the first line you wish to move; type <code>"add</code> to delete it to register <code>a</code>.
 
*Move to another line; type <code>"Add</code> to delete it and ''append'' to the same register.
 
*Move to another line; type <code>"Add</code> to delete it and ''append'' to the same register.
 
**or type "." for the same effect
 
*Select a range of lines vith V; type <code>"Ad</code> to delete the entire range and append it to the same register.
 
*Continue in this fashion.
 
 
*Move to the wanted destination.
 
*Move to the wanted destination.
 
*Press <code>"ap</code> to paste after the line with the cursor, or <code>"aP</code> to paste before.
 
*Press <code>"ap</code> to paste after the line with the cursor, or <code>"aP</code> to paste before.
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)