If I start with this file:
ddp, I expect to get this:
but instead I get this:
What am I doing wrong?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
Like husB commented you have to use a characterwise motion.
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
0includes whitespace, use
_instead to go to the first non-blank character
D: 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
dd: cuts the now empty line into
Instead of dd, can use: