Does anyone one know of a short key sequence that would do the equivalent of :1,-d:+,$d
? Yes, I know you can define a function, macro, and that would be nice. But, maybe a bit more elegant if you could hit some predefined keys, letters, controls, and get the same result.
1 Answer
Maybe this will do:
:v/\%#/d
That should deal with corner cases like the line you want to keep being the first line in the buffer, etc.
Or perhaps :move
the current line to the beginning of the buffer and delete the rest:
:m0|+,$d
or:
YggPjdG
To repeat later, either map it to a key, or maybe grab it from your history with :v<up>
for example.
References:
:help :v
:help /\%#
-
1
yyggdG"0P
on the line you want to preserve.. however that leaves a extra empty line.. you could also do:1,-d | +,$d
for single command line execution instead of two