Turning off auto-comment...yes, already tried that

718 views
Skip to first unread message

Andrew Fabbro

unread,
Feb 15, 2012, 5:33:55 PM2/15/12
to vim_use
I'm trying to turn off vim's auto-commenting feature. If possible,
irrevocably, permanently, for all time, and for all mankind.

If I type 'vi blah.pl', a shebang line, and then return, it continues
auto-commenting:

#!/usr/bin/perl
#
#

I'm sure someone finds this feature useful, but I do not. I'd like to
get rid of this auto-commenting.

My CentOS 6.1 /etc/vimrc ends with:

syntax off
set nohlsearch
set t_Co=0
set fo-=r

That last line is supposed to turn off auto-commenting...and oddly,
this does turn it off for root, but not for any other users. /etc/
vimrc is mode 644.

If I put those lines in a user's .vimrc in their home directory
(confirmed as the right place by :version), it still does not work.
The other lines do apparently work.

If I start a fresh session, type "set fo-=r" it then does work, but it
refuses to pick it up from a .vimrc. Very strange.

vim -C (which I thought made vim as vi-like as possible) still
autocomments as well.

Anyone have any further tips?

I've also tried

set fo-=cor

in /etc/vimrc and user's .vimrc with no change.

Here is my :version - I'm using vim in an ssh session, not a GUI:


VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Jun 25 2011 09:43:11)
Included patches: 1-411
Modified by <bugz...@redhat.com>
Compiled by <bugz...@redhat.com>
Huge version without GUI. Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset
+cindent -clientserver -clipboard +cmdline_compl
+cmdline_hist +cmdline_info +comments +cryptv +cscope +cursorshape
+dialog_con +diff +digraphs -dnd -ebcdic +emacs_tags
+eval +ex_extra +extra_search +farsi +file_in_path +find_in_path
+float +folding -footer +fork() +gettext
-hangul_input +iconv +insert_expand +jumplist +keymap +langmap
+libcall +linebreak +lispindent +listcmds +localmap
+menu +mksession +modify_fname +mouse -mouseshape +mouse_dec
+mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse
+mouse_xterm +multi_byte +multi_lang -mzscheme -netbeans_intg -
osfiletype +path_extra +perl +postscript +printer
+profile +python +quickfix +reltime +rightleft -ruby +scrollbind
+signs +smartindent -sniff +startuptime +statusline
-sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl
+terminfo +termresponse +textobjects +title
-toolbar +user_commands +vertsplit +virtualedit +visual +visualextra
+viminfo +vreplace +wildignore +wildmenu +windows
+writebackup -X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -
Wall -fexceptions -fstack-protector --param=ssp-buffe
r-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -
D_FORTIFY_SOURCE=1 -D_REENTRANT -D_GNU_SOURCE -f
stack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -
D_FILE_OFFSET_BITS=64 -I/usr/lib64/perl5/CORE -I/usr/include
/python2.6 -pthread
Linking: gcc -Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE -L/usr/local/
lib -o vim -lselinux -lncurses -lacl -lgpm
-Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE -fstack-protector -L/usr/
lib64/perl5/CORE -lperl -lresolv -lutil -lc -L/usr/
lib64/python2.6/config -lpython2.6 -lutil -lm -Xlinker -export-dynamic



Gary Johnson

unread,
Feb 16, 2012, 2:25:04 AM2/16/12
to vim_use
On 2012-02-15, Andrew Fabbro wrote:
> I'm trying to turn off vim's auto-commenting feature. If possible,
> irrevocably, permanently, for all time, and for all mankind.
>
> If I type 'vi blah.pl', a shebang line, and then return, it continues
> auto-commenting:
>
> #!/usr/bin/perl
> #
> #
>
> I'm sure someone finds this feature useful, but I do not. I'd like to
> get rid of this auto-commenting.
>
> My CentOS 6.1 /etc/vimrc ends with:
>
> syntax off
> set nohlsearch
> set t_Co=0
> set fo-=r
>
> That last line is supposed to turn off auto-commenting...and oddly,
> this does turn it off for root, but not for any other users. /etc/
> vimrc is mode 644.

I believe the problem is in $VIMRUNTIME/ftplugin/perl.vim, line 15:

setlocal formatoptions+=crq

That line is executed whenever you open or create a Perl file. The
solution is to put

setlocal fo-=r

in the (new) file ~/.vim/after/ftplugin/perl.vim.

> Here is my :version - I'm using vim in an ssh session, not a GUI:
>
>
> VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Jun 25 2011 09:43:11)
> Included patches: 1-411

The $VIMRUNTIME/ftplugin/perl.vim file I looked at was the version
last changed on 2009-08-14, so it isn't the version you have, but it
probably still has that line.

HTH,
Gary

Ben Fritz

unread,
Feb 16, 2012, 10:45:05 AM2/16/12
to vim_use


On Feb 16, 1:25 am, Gary Johnson <garyj...@spocom.com> wrote:
>
> I believe the problem is in $VIMRUNTIME/ftplugin/perl.vim, line 15:
>
>     setlocal formatoptions+=crq
>
> That line is executed whenever you open or create a Perl file.  The
> solution is to put
>
>     setlocal fo-=r
>
> in the (new) file ~/.vim/after/ftplugin/perl.vim.
>

Or, since the OP wants to turn off this feature "irrevocably,
permanently, for all time, and for all mankind" it's probably better
to do it for all filetypes, in the .vimrc:

autocmd FileType * setlocal fo-=r

Probably you'll also want to remove the 'o' flag as well:

autocmd FileType * setlocal fo-=r fo-=o
Reply all
Reply to author
Forward
0 new messages