Thursday, October 25, 2012

Re: Global configuration in after directory possible?

On Friday, 19 October 2012 20:11:25 UTC+1, Tony Mechelynck wrote:
> 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.

> 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.)

This is the solution I settled on. Gary's command also
worked for me but this one seems to cover more obscure
scenarios, and I like the idea of chaining two autocommands
together - neat.

What C Campbell suggested was something I orginally tried
and couldn't make work at all, because I didn't understand
how the after-directory works. I just created
~/vimfiles/after/_vimrc_afterwards as a file and it seemed
to ignore it. I didn't think of doing it as a plugin. I'll
bear that in mind as a general technique in future.

> 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?

Actually I don't use autowrapping at all, but I have
'textwidth' set so I can do 'gq' to wrap the text when
necessary.

It works for me because I don't need to print anything from
vim out (yet :)

> 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.

It didn't remove the flag, I'm not sure why. I don't think
I ever turn it off anyway so it's not a problem in my case.

> Best regards,
> Tony.
> --

Thanks to everyone who suggested things. I've learnt quite
a bit about how the after-directory works and got a working
solution. Much appreciated.

regards,
Geoff

--
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

No comments: