Vim: delete empty lines around cursor
vim
Solution
Easy. In normal mode, `dipO<Esc>` should do it.
Explanation:
- `dip` on a blank line deletes it and all adjacent blank lines.
- `O<Esc>` opens a new empty line, then goes back to normal mode.
Even more concise, `cip<Esc>` would roll these two steps into one, as suggested by @Lorkenpeist.
Problem
Suppose I'm editing the following document (* = cursor): ``` Lions Tigers Kittens Puppies * Humans ``` What sequence can I use to delete the surrounding white space so that I'm left with: ``` Lions Tigers Kittens Puppies * Humans ``` Note: I'm looking for an answer that handles any number of empty lines, not just this exact case. EDIT 1: Line numbers are unknown and I only want to effect the span my cursor is in. EDIT 2: Edited example to show I need to preserve leading whitespace on edges Thanks