0

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?

Zombo
  • 1
  • 5
  • 18

2 Answers2

1

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 character
  • D: cut characterwise to the end of the line
    • also includes whitespace, can be replaced by 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) clean
  • dd: cuts the now empty line into "_
id -un
  • 33
  • 4
0

Instead of dd, can use:

D

Or:

dEnd

https://fprintf.net/vimCheatSheet.html

Zombo
  • 1
  • 5
  • 18