man.vim: Fix very long justified lines #9023

When nroff justifies a line, it fills the line with whitespace to meet
$MANWIDTH.  With $MANWIDTH=9999, that of course results in nonsense (and
behaves poorly with 'cursorline' option).

To work around that, instead of trying to hard-justify the lines, just
replace the mega-whitespace with a fixed size of 10 spaces.

Perhaps N/Vim needs a "soft justify" feature?
This commit is contained in:
Justin M. Keyes 2018-09-21 09:08:39 +02:00
parent 9081cad514
commit dc256e376d

View File

@ -167,6 +167,10 @@ function! s:put_page(page) abort
while getline(1) =~# '^\s*$'
silent keepjumps 1delete _
endwhile
" XXX: nroff justifies text by filling it with whitespace. That interacts
" badly with our use of $MANWIDTH=9999. Hack around this by using a fixed
" size for those whitespace regions.
silent! keeppatterns keepjumps %s/\s\{999,}/\=repeat(' ', 10)/g
lua require("man").highlight_man_page()
setlocal filetype=man
endfunction