Brian Anderson wrote:
Tony,
Thanks for the reply.
I can reformat the current document with gggqG as you said, but when I
start typing again, the text is not breaking.
The files were adding line breaking automatically, but then I guess I
changed something (I don't know what). Now it isn't adding any more line
breaks. I'd like to get that back, and figure out what I did that
changed it in the first place.
Brian
PS: I was using a session file, with a textwidth of 80, and a wrapmargin
of 10. I deleted the session, checked that textwidth was set to 80, and
wrapmargin to 0, exited vim, restarted and recreated my session file.
The files are breaking now. Did I have a setting wrong when I created
the session file?
'textwidth' and 'wrapmargin' are not useful together:
- If 'textwidth' is non-zero, lines break at that distance from the left side,
regardless of the 'wrapmargin' setting.
- If 'textwidth' is zero and 'wrapmargin' is nonzero, lines break at that
distance from the right side (of the Vim window).
- If they are both zero, lines don't break.
These are buffer-local options: you can set them to different values in
different buffers, by means of the ":setlocal" command or of a modeline.
In addition, the following flags of the 'formatoptions' option are relevant:
t format all text using 'textwidth'
c format comment text using 'textwidth', inserting the comment leader
q gq will format comments
w any line which ends in a non-whitespace is the last line of its
paragraph
a autoformat paragraphs (or comments only, if c is present) whenever
text is added or deleted.
v only break lines at blanks that you have added during the present
insert
l (L-for-Lima) don't break long lines in Insert mode
m allow breaking between multibyte characters (such as CJK wide
characters)
1 (one) don't break line after a one-letter word
The 'nocompatible' default is tcq (and the 'compatible' default is vt) unless
set differently by a filetype-plugin (e.g., the C plugin sets it to croql).
Some filetype-plugins or other autocommands change these options: for
instance, the vimrc_example.vim sets 'textwidth' to 78 whenever 'filetype' is
set to "text".
I don't use session scripts much, so I don't know the details: the only
session files I use are those created automatically by the Gnome version of
Vim when the Gnome or kde window manager is closed down and sourced
automatically after restarting it.
I'm cc-ing this to the Vim mailing list: maybe someone will give you an even
more detailed answer, or clarify points I left in the dark.
Best regards,
Tony.
--
Computer Science is merely the post-Turing decline in formal systems
theory.