Are you still having problems moving text around in vim? Here are some pointers.
Cheat sheet
move lines with dd and p
Getting started with block mode
- moving around with o and O
- delete with x or d
- yank with y – then put before with P and put after with p
- yank and put after some short lines y$p
- insert text into multiple lines with A and I
View the register with :registers
Indent an entire file with gg=G
Thanks a lot! More Vim, please.
good post! I´m getting to know vim, this was very useful!
would love to see some screencasts on tim pope´s plugins, they seem great!
Great job. Practical and useful. Will be using these commands today! Thank you!
Awesome!
Great job, Bryan! I used to teach vi way back in the day. Here are some more tips for manipulating text:
You can preface many commands with a number, indicating the number of chars or words or lines you want to work on.
5dd (delete the next 5 lines)
10yy (yank the next 10 lines)
p (put the yanked/deleted lines below the caret)
Working with words – you can change words or delete words
3cw (puts you in edit mode to overwrite the next 3 words)
5dw (delete the next 5 words)
'u' is Undo
Joining lines – use capital J on a line to pull up the next line
Doing the same thing over and over again? Hit period to repeat the last command. Works really well when deleting indentation – 4x (delete 4 spaces), then down arrow, period, down arrow, period, etc
Capital G is “go”. So 30G goes to line 30. ctrl-g shows you status (current line #)
You can specify blocks using numbers too. Bryan, you touched on this with g and G. If you want to work on lines 5 thru 16, you could type :5,16d (to delete them for example)
This was always one of my favorite vi cheatsheets: http://www.eec.com/business/vi.html
Have fun in vim! BTW, I use vim all the time, but for serious coding I stay in TextMate.
The geek vids are great. Thanks!