Is it possible to reformat/reflow text files into two-column layouts (as in some newspapers)? I can do that in Word, but I'd rather do it in vim.
Based on this unix.se answer, I would do
:%!pr -t -2 -w 200
Or some appropriate width (e.g., to insert twice
textwidth, type Ctrl-r
=&textwidth*2Enter after the
You can reuse split windows for that.
Sequence of commands:
:vsplitto vertically split window
:set scrollbindto bind current window scroll with new window
:<C-w>wto go to new split window
:<C-f>to scroll this new window one page down
:set scrollbindto bind this window scroll to prev window
Now you have emulation of "two-column" layout.
I actually have this kind of command (named differently though, but here it would be called
" Two columns. " 1. Vertically split window " 2. Offset it one screen " 3. Scrollbind command! TwoColumns \ exe "normal zR" \ | set noscrollbind \ | vsplit \ | set scrollbind \ | wincmd w \ | exe "normal \<c-f>" \ | set scrollbind \ | wincmd p
It additionally opens all folds, resets scrollbind and goes back to current window in the end.
PS, this command depends on default value of
splitright (off by default). If
splitright is set, one have to slightly change the command.