junegunn / goyo.vim

:tulip: Distraction-free writing in Vim
MIT License
4.49k stars 115 forks source link

Relationship between wrapmargin and textwidth setting in vimrc and goyo mode formatting/rendering #274

Open TryerGit opened 1 year ago

TryerGit commented 1 year ago

Hello,

Currently, my vimrc is as follows:

set colorcolumn=80
set number relativenumber
set textwidth=0
set wrapmargin=5
set linebreak
set formatoptions=at

I performed the experiment whose animaged gif is available here: https://imgur.com/quLvk6R

In this experiment, beginning with my terminal maximized to full screen, I wrote out a few long sentences in a paragraph. Due to the settings above, vim automatically wraps at 5 columns to the left of the right edge of the terminal. This is as expected.

Then, I entered Goyo mode. At this stage, with what format options does Goyo format/render the paragraph above? Specifically, does Goyo respect wrapmargin settings or textwidth settings from the user's vimrc? I notice that the default settings are:

g:goyo_width (default: 80)

What is the relationship between the textwidth setting in the user's vimrc and the Goyo default of 80? If I understand correctly, both settings should be the same. With g:goyo_linenr set to 1, however, g:goyo_width should be 2 to 3 column widths more as compared to the user's textwidth setting in vimrc so that toggling to Goyo mode does not render the width of an 80 column wide paragraph in an artificial fashion because the line number takes away 2 or 3 columns. Is my understanding correct?

Continuing with the experiment in the gif, I then selected the long paragraph and formatted it by issuing gq over the visual selection of the paragraph. When I toggle Goyo off, I expected that the original formatting before entering Goyo mode would be returned back and displayed. However, it is not preserved and the original formatting before entering Goyo mode is lost. The Goyo mode's formatting (after having issued gq) is what is preserved. This is not necessarily a problem, but I am trying to wrap my head around the wrapmargin, textwidth, g:goyo_linenr and g:goyo_width settings and how these interact and affect the display as one toggles in and out of Goyo mode.

Thanks for the very useful plugin.