I'm doing a lot of text manipulation between multiple files that requires a lot of yy
, dd
and p
ing. This may sound crazy but is there some shorter way of doing dd
and p
in one go? Maybe even with a plugin?
Deleting Multiple Lines in Vi and VimInstead of simply pressing dd, you can specify the number of lines you want to delete. For example, typing 3dd will delete the next three lines from the file. You can also use wildcard characters in the aforementioned command.
Using the Shift + V Keys. We can select and delete specific texts using the Shift + V keys and then using the dd command.
Place the cursor on the line you wish to copy. Type yy to copy the line. Move the cursor to the place you wish to insert the copied line. Type p to insert the copied line after the current line on which the cursor is resting or type P to insert the copied line before the current line.
You can just make a map:
:map J ddp
and then J (or whatever you want) will do the combined operation.
Incidentally, I always map D to dd
, since I delete entire lines much more often than to the end of the line. That makes it easy to use Dp to do your task.
I typically just use:
Shift+v (selects the whole line)
and then
p (pastes over the selected line with your current register)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With