I turned on filetype plugin for some rails vim plugins I added, but a side effect of this seems to be that now autocommenting has been enabled in all filetypes (for instance, if I start a line with #, the next line, either by Enter in insert mode or O, etc. to enter insert mode, will also get a #).
I found a guide to disabling the auto-commenting formatoptions, and added the following to my .vimrc:
au FileType * setlocal formatoptions-=cro
However, I am still running into problems -- unless I explicitly :source .vimrc, (or enter the setlocal ... directly), it is not taking effect. I determined that this is the case because vim's ftplugins are overriding my options with their own.
I then found a second guide which talks about using an after ftplugin script to make changes after the ftplugin scripts have run, however their solution is to create symlinks for every single filetype in ~/.vim/after/ftplugin to a central file, and this seems to be kludgy to me.
Is there any way to create a generic after-ftplugin script or am I approaching this problem incorrectly? Any help would be appreciated.
How about an "after" plugin? Create a file in
~/.vim/after/plugin/callednoAutoComments.vim(or whatever) and place your autocmd in that?Edit:
The reason this works? I'm only guessing here, but I have a feeling that the
autocmdin the~/.vimrcfile is getting removed by some other file (but before the "after" files are getting sourced).I ended up removing my
~/.vimdirectory and replaced my~/.vimrcwith the following 3 lines:With only these lines in my
~/.vimrcand no~/.vim/directory, theautocmdseems to work as expected (Vim 7.1).For any file that I edit:
I have yet to determine what file (plugin) is causing this issue however.