On 19/10/12 19:01, lessthanideal wrote:
A lot of ftplugin files turn comment-wrapping on with a
command like this:

set formatoptions+=c

I want to globally disable it.  Is there an easy way to do
this?  I know I can disable it for particular filetypes by
creating files in vimfiles\after\ftplugin\ specifying "set
formatoptions-=c" but there are a lot of them.

Two methods I've found from searching are

. Maintain a single file and use symbolic links to make vim
access it for each filetype.  A bit clumsy - new filetypes
might appear later, I want to maintain real
filetype-specific files as well, etc.

. Use autocmd events to set this.  This works in many cases
but different edge cases are missed by different events so
I'm not sure which events to use.  Also it seems to be
"fighting vim" - trying to keep checking in case vim has
changed the setting and change it back.  I'd like it to just
work, reliably.

Is there a simpler method?

regards,
Geoff


Try adding this near the end of your vimrc:

        au VimEnter * au FileType * setlocal fo-=c

This is supposed to add ":setlocal fo-=c" at the end of the list of FileType autocommands for any filetype. (The VimEnter event is triggered at the very end of startup.)

The problem is that if you forget to break lines when typing a comment, you might find yourself with a single-line comment of, let's say, 1000 characters, which might be, hm, shall we say, a little awkward?

Another possible problem is that if you use the "filetype plugin off" command, it may disable this autocommand, which won't be set again by "filetype plugin on". In that case you should add it near the end of a ~/.vim/after/filetype.vim (for Unix / Linux / Mac OSX) or ~/vimfiles/after/filetype.vim (for Windows) (neither this file nor its directory exist by default, create them if necessary, DON'T modify $VIMRUNTIME/filetype.vim):

"------------------------------------filetype.vim start
augroup filetypedetect
"
" ... maybe some custom filetype-detection if-clauses
"
au FileType * setlocal fo-=c

augroup END
"------------------------------------filetype.vim end

Thus will be set again every time you do ":filetype [plugin] [indent] on". I am less sure that this will remove the c flag *after* it has been set though.


Best regards,
Tony.
--
From the Pro 350 Pocket Service Guide, p. 49, Step 5 of the
instructions on removing an I/O board from the card cage, comes a new
experience in sound:

        5.  Turn the handle to the right 90 degrees.  The pin-spreading
            sound is normal for this type of connector.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to