This service will be undergoing maintenance at 20:00 UTC, 2017-04-03. It is expected to last about 30 minutes
Bug 99437 - vim no longer autoindents C code
vim no longer autoindents C code
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: vim (Show other bugs)
9
All Linux
medium Severity medium
: ---
: ---
Assigned To: Karsten Hopp
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-07-19 11:20 EDT by Need Real Name
Modified: 2007-04-18 12:55 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-07-31 07:34:00 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2003-07-19 11:20:18 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030701

Description of problem:
As shipped with Red Hat 9, vim no longer automatically sets cindent when editing
C code.  This is different (and less desireable) from vim as shipped with all
previous versions of Red Hat, at least as far back as Red Hat 7.1, and I believe
much earlier.  I am in shock that this has not been reported earlier...  I'd
have expected people to have noticed, and to complain.

Note that if you are not seeing this, it is almost certainly because you have
something in your .vimrc which is enabling cindent (or one of the other
auto-indent features).  Rename your .vimrc and any .vim directory, and you
should see the problem.  Except, well, you shouldn't.

I identified where the problem is by perusing a recursive diff of
/usr/share/vim/vim61 on each of a Red Hat 8 and Red Hat 9 system. Doing so
reveals the following code which is present in RH8, but missing from RH9, which
when applied with patch -p1 fixes the problem:

--- RH9/macros/vimrc    2003-02-12 07:44:38.000000000 -0500
+++ RH8/macros/vimrc    2002-12-23 17:02:48.000000000 -0500
@@ -45,6 +45,44 @@
   set hlsearch
 endif
 
+if has("autocmd")
+ augroup cprog
+  " Remove all cprog autocommands
+  au!
+
+  " When starting to edit a file:
+  "   For C and C++ files set formatting of comments and set C-indenting on.
+  "   For other files switch it off.
+  "   Don't change the order, it's important that the line with * comes first.
+  autocmd FileType *      set formatoptions=tcql nocindent comments&
+  autocmd FileType c,cpp  set formatoptions=croql cindent comments=sr:/*,mb:*,e
l:*/,://
+ augroup END
+
+ augroup gzip
+  " Remove all gzip autocommands
+  au!
+
+  " Enable editing of gzipped files
+  "      read: set binary mode before reading the file
+  "            uncompress text in buffer after reading
+  "     write: compress file after writing
+  "    append: uncompress file, append, compress file
+  autocmd BufReadPre,FileReadPre       *.gz set bin
+  autocmd BufReadPost,FileReadPost     *.gz let ch_save = &ch|set ch=2
+  autocmd BufReadPost,FileReadPost     *.gz '[,']!gunzip
+  autocmd BufReadPost,FileReadPost     *.gz set nobin
+  autocmd BufReadPost,FileReadPost     *.gz let &ch = ch_save|unlet ch_save
+  autocmd BufReadPost,FileReadPost     *.gz execute ":doautocmd BufReadPost " .
 expand("%:r")
+
+  autocmd BufWritePost,FileWritePost   *.gz !mv <afile> <afile>:r
+  autocmd BufWritePost,FileWritePost   *.gz !gzip <afile>:r
+
+  autocmd FileAppendPre                        *.gz !gunzip <afile>
+  autocmd FileAppendPre                        *.gz !mv <afile>:r <afile>
+  autocmd FileAppendPost               *.gz !mv <afile> <afile>:r
+  autocmd FileAppendPost               *.gz !gzip <afile>:r
+ augroup END
+endif
 if &term=="xterm"
      set t_Co=8
      set t_Sb=^[4%dm


Version-Release number of selected component (if applicable):
vim-enhanced-6.1-29

How reproducible:
Always

Steps to Reproduce:
1. vim somefile.c
2. type code
3. notice lack of indenting
    

Expected Results:  C code should be indented.

Additional info:
Comment 1 Karsten Hopp 2003-07-31 07:34:00 EDT
Setting these autocommands in /usr/share/vim/vim*/macros/vimrc would overwrite any  
user settings. Please have a look at bug #84088 for an explanation why the autocommands 
have been removed from the global vimrc. 
 

Note You need to log in before you can comment on or make changes to this bug.