diff options
-rw-r--r-- | runtime/autoload/man.vim | 9 | ||||
-rw-r--r-- | runtime/ftplugin/man.vim | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 7385862c0b..8ca78f2782 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -149,8 +149,9 @@ function! s:system(cmd, ...) abort endfunction function! s:get_page(path) abort - " Respect $MANWIDTH or default to window width. - let manwidth = empty($MANWIDTH) ? winwidth(0) : $MANWIDTH + " Disable hard-wrap by setting $MANWIDTH to a high value. + " Use soft wrap instead (ftplugin/man.vim sets 'wrap', 'breakindent'). + let manwidth = 9999 " Force MANPAGER=cat to ensure Vim is not recursively invoked (by man-db). " http://comments.gmane.org/gmane.editors.vim.devel/29085 " Set MAN_KEEP_FORMATTING so Debian man doesn't discard backspaces. @@ -166,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 diff --git a/runtime/ftplugin/man.vim b/runtime/ftplugin/man.vim index 68ebb33e45..26b51186a1 100644 --- a/runtime/ftplugin/man.vim +++ b/runtime/ftplugin/man.vim @@ -22,6 +22,8 @@ setlocal noexpandtab setlocal tabstop=8 setlocal softtabstop=8 setlocal shiftwidth=8 +setlocal wrap +setlocal breakindent setlocal nonumber setlocal norelativenumber @@ -31,6 +33,8 @@ setlocal nolist setlocal nofoldenable if !exists('g:no_plugin_maps') && !exists('g:no_man_maps') + nnoremap <silent> <buffer> j gj + nnoremap <silent> <buffer> k gk nnoremap <silent> <buffer> gO :call man#show_toc()<CR> nnoremap <silent> <buffer> <C-]> :Man<CR> nnoremap <silent> <buffer> K :Man<CR> |