vim-utils / vim-man

View and grep man pages in vim
247 stars 32 forks source link

Reformat text on window resize #14

Open jebaum opened 9 years ago

jebaum commented 9 years ago

If you vertically resize a window containing a manpage, the text remains formatted to fit whatever the original window size was. If the window was originally small and you make it wider, the text doesn't use any of the additional space. Conversely, if the window was originally wide and you make it narrower, it wraps in ways that make it difficult to read. I haven't looked at the code at all so I have no idea how this is done, but I think it would be useful to expose a mapping to reformat the text for the current window size, or for gvim, hook into the VimResized autocmd.

bruno- commented 9 years ago

Hey thank you for trying out the plugin. I'd recommend setting the text width to 80 columns. There's an option for that (not documented yet): let g:man_width = 80. That's pretty narrow compared to monitor size so it should fit in pretty much any window, no matter how small. Also, I find 80 columns text easier to read.. maybe it should even be the default.

The issue with reformatting the window is that it's cumbersome and won't work well with Mangrep.

Btw. did you get to use mangrep feature? I'd appreciate some feedback on that.

jebaum commented 9 years ago

I tried mangrep out of curiousity, although I haven't had an actual need to do it (ever, I think...). It worked very well! Not something I think you would need very often but very handy when you do. In case anyone stumbles on this conversation, if you lazy load dispatch with vim-plug or neobundle, mangrep can't use it unless it's already been loaded. So either don't lazy load dispatch, or write some vimL to call plug#load('vim-dispatch') before running mangrep.

The textwidth option sounds like a decent workaround. The map in the pull request I opened works perfectly (minus the part where it loses your place in the buffer), and it's only a single line of code. Knowing about g:man_width I'm on the fence about it. Sometimes I do end up with screens less than 80 columns and in that case, having the option to format dynamically is nice.