Move text quickly in vim. When you start out in vim, you might:
- First, delete the text
- Then, move your cursor to the desired location
- Finally, put the text before or after the cursor (using P/p, respectively).
Next time, use ex commands to do this like a boss!
For example, let's assume you want to move line numbers 10-20 to line 8. You would do this by entering:
Let me explain the above:
- The colon brings you into ex mode.
- The first 10: line number 10
- The semicolon: used so that the next number is calculated relative to the first.
- +10 : means add to the first number
- m: means move
- 8: the line number where you want to move the text
Source: I learned this from Learning the vi and vim editors, 7th edition by By Arnold Robbins, Elbert Hannah, Linda Lamb