linda.s wrote:
After I set textwidth=66 in the .gvimrc and .vimrc, I edited my vim
file. I tried adding one new word but the the original well-displayed
paragraph immediately appeared as if there was no textwidth setting.
Why?
What is your 'formatoptions' setting? (Place the cursor in the file in
question and then do:
:setlocal formatoptions?
). The filetype-plugins for most programming languages, including vimscript I
think, set 'formatoptions' so that *code* won't be auto-reformatted. Only
*comments* can be -- and that's intentional. Let's take an example out of my
vimrc: it starts with
------------------------------
set nocompatible
scriptencoding latin1
if &mm < 256
set mm=20000000
endif
if &mmt < 256
set mmt=20000000
endif
if has("multi_lang")
if has("unix")
language messages C
else
language messages en
endif
endif
runtime vimrc_example.vim
color almost-default
------------------------------
which is valid vimscript code. Now if it were "reformatted" to 78 columns as
for (novel etc.) text, I would get
------------------------------
set nocompatible scriptencoding latin1
if &mm < 256 set mm=20000000 endif if &mmt < 256 set mmt=20000000 endif
if has("multi_lang") if has("unix") language messages C else language messages
en endif endif
runtime vimrc_example.vim color almost-default
------------------------------
which is not valid vimscript at all, because ends-of-lines are significant in
vimscript, and removing them either introduces syntax errors (usually) or
totally changes the meaning.
To keep the meaning while packing it to 78-character length, you would have to
add characters which aren't in the original, as in
------------------------------
set nocompatible | scriptencoding latin1 | if &mm < 256 | set mm=20000000
endif | if &mmt < 256 | set mmt=20000000 | endif | if has("multi_lang")
if has("unix") | language messages C | else | language messages en | endif
endif | runtime vimrc_example.vim | color almost-default
------------------------------
which is maybe valid but certainly ugly, and bad programming style.
Best regards,
Tony.
--
"They're unfriendly, which is fortunate, really. They'd be difficult
to like."
-- Avon