I want to tell a command or mapping to advance to the next non-blank line before executing - but to do this only if the current line is not blank.
Ultimately, I intend to apply this to a command to collapse blank lines in a given range, replacing the blank lines with tabs. This must be done from the first non-blank line to prevent preceding newlines becoming tabs ahead of the first word of the collapsed line.
So I might find the next non-blank line with /^.\+/
I want to apply that to this command that collapses blank lines:
:command -range=0 CollapseLines <line1>,<line2>s/\n/\t/
For example, like this:
:command -range=0 CollapseLines /^.\+/<line1>,<line2>s/\n/\t/
But if I combine the two, it advances to the next non-blank line in disregard of whether the current line is blank or not. So the first line of the range gets missed.
Finally, I intend to use this with a mapping:
:nmap <leader>cl :CollapseLines<CR>j
So the placing of the cursor on the first or current non-blank line might be done in the mapping rather than the command.