If I start with this file:
https://example.com
<>
and press ddp, I expect to get this:
<https://example.com>
but instead I get this:
<>
https://example.com
What am I doing wrong?
If I start with this file:
https://example.com
<>
and press ddp, I expect to get this:
<https://example.com>
but instead I get this:
<>
https://example.com
What am I doing wrong?
Like husB commented you have to use a characterwise motion.
Note that D deletes from the current cursor position to the end of the line and doesn't delete the line itself.
You could overwrite what dd does but I would recommend you map your expected behaviour to a new command, <leader>d in the following mapping:
:nmap <leader>d 0D"_dd
The command does the following:
0: go to the beginning of the line
0 includes whitespace, use ^ or _ instead to go to the first non-blank characterD: cut characterwise to the end of the line
dg_ to cut to the last non-blank character instead, see this answer"_ is the "black hole register" to keep your default register (used by p) cleandd: cuts the now empty line into "_
ddperforms a linewise operation. To paste within the current line, the delete operator needs to be a given a characterwise motion. More details here – husB Mar 03 '20 at 05:28DJp– filbranden Mar 03 '20 at 06:11