Comments From VIM, Nevermore!Has anyone else noticed how the newer versions of VIM attempt to be smart? Yeah, they think that just because you typed a comment on one line that you want to comment the next line, and the next, and the next. I don't know about you, but I'll tell the program which lines I want to comment, not the other way around. There has to be some way to tell VIM to never autocomment a line, ever.
First, you need to see what rules VIM is using for autocommenting. VI a random file and enter
:setlocaland hit ENTER. In case you're VIM-dumb, the colon gets you into command mode, so don't put yourself in insert mode and then type the command. It won't work. If it did work, you'll see a list of local configuration parameters
:setlocal --- Local option values --- --autoread errorformat= keywordprg= scroll=11 comments=:# grepprg= makeprg= tags= define= include= path= formatoptions=tcqlor if your autocommenting is more ridiculous you may see
:setlocal --- Local option values --- --autoread grepprg= makeprg= tags= define= include= path= errorformat= keywordprg= scroll=11 comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-,:# formatoptions=tcqlWhatever you see, you'll notice the line that begins with "comments."
My config looked like the first one, so I only had to find a way to remove :# from the list. Piece of cake.
In your home directory, make a .vimrc file (if you don't already have one) and put the setlocal command in there.
# cat ~/.vimrc setlocal comments-=:#That tells it to keep the value of "comments," but remove :#. In my case, :# was the only value, so "comments" was empty afterward. You can modify this to your liking if you have the need of removing/adding more types of comments.
UPDATE 2009-01-26: From the comments, multiple people have said that the above way does not work. One such issue was due to vim's filetype detection, which happens AFTER your .vimrc gets sourced, nullifying what you wrote. To get around this and remove autocomments for all files, add this line to the end of your .vimrc:
au FileType * setlocal comments=