Vim: add macro for rebalancing/resorting text in columns

I previously wrote up how to do this here:

  https://wincent.com/wiki/Multi-column_layout_in_Vim

Rather than manually performing those steps, let's just stick them in a
macro. I've split it up over multiple lines to make it clearer what it
is doing. Note that there is some weirdness with doing forward searches
(`/`) in mappings, most likely due to my mapping elsewhere to default to
`/\v`, so in the macro I search backwards instead (`?`).

Here is a breakdown:

  vnoremap <leader>zc <Esc> " get out of VISUAL mode
    \`<O=====<Esc>          " jump to start of last selection, prepend marker string "=====" on line above
    \`>o=====<Esc>          " jump to end of last selection, append marker string on line below
    \kV?=====<CR>           " move up one line, enter VISUAL mode, search for starting marker
    \j:s/\v  +/\r/g<CR>     " move down one line, split columns into individual lines
    \V?=====<CR>            " back into VISUAL mode, search back to starting marker
    \j:g/^$/d<CR>           " move down one line, remove blank lines
    \?=====<CR>             " search back to start marker
    \jVNk:sort<CR>          " move down one line, enter VISUAL mode, move to end marker, up one line, sort selection
    \gv:!column -c 78<CR>   " reselect last selection, columnify
    \:set tabstop=8<CR>     " match tabstop setting usd by `column` executable
    \VNk:retab<CR>          " back to VISUAL mode, select to end marker, convert tabs to spaces
    \gv>Nddndd              " reselect last selection, indent, delete markers

As I write this, it occurs to me that we might be able to simplify this
by improving the column splitting regex to avoid creating empty blank
lines. I'll look into that after this.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Vim: shorten column macro

As noted in the last commit, I suspect I could make this macro simpler
by changing the regex to deal better with leading whitespace. This is
the result. It's still not perfect (for example, it makes no attempt to
save and restore the original tab-stop setting), but it works.

Note: the trailing whitespace on the first line is significant.

  vnoremap <leader>zc
    \:s/\v^ +//g<CR>       " remove leading whitespace
    \gv:s/\v  +/\r/g<CR>   " reselect last selection, split columns onto lines
    \gvj:sort<CR>          " reselect last selection, sort
    \V}k:!column -c 78<CR> " select region, columnify
    \:set tabstop=8<CR>    " set tabstops to match `column` executable
    \V}:retab<CR>          " select region again; convert tabs to spaces
    \gv>:noh<CR>           " indent, and remove search highlighting

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Vim: save and restore tabstop setting in column macro

Signed-off-by: Wincent Colaiuta <win@wincent.com>