1

When I use braces (, the indenting is screwed up. Filetype is not set (but it's the same if I set it to e.g. txt). Here's what I type:

foo<CR>bar<CR>foo (<CR>bar

Here's how it looks like in vim

foo
bar
foo (
        bar

Why does the second bar get indented? I have auto indent and cindent in my .vimrc.

Here's the output of :scriptnames:

  1: /etc/vimrc
  2: /usr/share/vim/vimfiles/archlinux.vim
  3: ~/.vimrc
  4: /usr/share/vim/vim80/filetype.vim
  5: /usr/share/vim/vimfiles/ftdetect/dockerfile.vim
  6: /usr/share/vim/vim80/ftplugin.vim                                                        
  7: /usr/share/vim/vim80/indent.vim                                                          
  8: ~/.vim/autoload/pathogen.vim                                                             
  9: /usr/share/vim/vim80/ftoff.vim                                                           
 10: /usr/share/vim/vim80/syntax/syntax.vim                                                   
 11: /usr/share/vim/vim80/syntax/synload.vim                                                  
 12: /usr/share/vim/vim80/syntax/syncolor.vim                                                 
 13: ~/.vim/colors/peaksea.vim                                                                
 14: ~/.vim/plugin/Bclose.vim                                                                 
 15: ~/.vim/plugin/NERD_tree.vim                                                              
 16: ~/.vim/plugin/a.vim                                                                      
 17: ~/.vim/plugin/conque_gdb.vim                                                             
 18: ~/.vim/autoload/conque_gdb.vim                                                           
 19: ~/.vim/autoload/conque_term.vim                                                          
 20: ~/.vim/plugin/conque_term.vim                                                            
 21: ~/.vim/plugin/toggle.vim                                                                 
 22: ~/.vim/plugin/yankstack.vim                                                              
 23: ~/.vim/autoload/yankstack.vim                                                            
 24: ~/.vim/bundle/gundo/plugin/gundo.vim                                                     
 25: ~/.vim/bundle/syntastic/plugin/syntastic/autoloclist.vim                                 
 26: ~/.vim/bundle/syntastic/plugin/syntastic/balloons.vim                                    
 27: ~/.vim/bundle/syntastic/plugin/syntastic/checker.vim                                     
 28: ~/.vim/bundle/syntastic/plugin/syntastic/cursor.vim                                      
 29: ~/.vim/bundle/syntastic/plugin/syntastic/highlighting.vim                                
 30: ~/.vim/bundle/syntastic/plugin/syntastic/loclist.vim                                     
 31: ~/.vim/bundle/syntastic/plugin/syntastic/modemap.vim                                     
 32: ~/.vim/bundle/syntastic/plugin/syntastic/notifiers.vim                                   
 33: ~/.vim/bundle/syntastic/plugin/syntastic/registry.vim                                    
 34: ~/.vim/bundle/syntastic/plugin/syntastic/signs.vim                                       
 35: ~/.vim/bundle/syntastic/plugin/syntastic.vim                                             
 36: ~/.vim/bundle/syntastic/autoload/syntastic/util.vim                                      
 37: /usr/share/vim/vimfiles/plugin/SyntaxFolds.vim                                           
 38: /usr/share/vim/vimfiles/plugin/a.vim                                                     
 39: /usr/share/vim/vimfiles/plugin/filebrowser.vim                                           
 40: /usr/share/vim/vimfiles/plugin/imaps.vim                                                 
 41: /usr/share/vim/vimfiles/plugin/remoteOpen.vim                                            
 42: /usr/share/vim/vim80/plugin/getscriptPlugin.vim                                          
 43: /usr/share/vim/vim80/plugin/gzip.vim                                                     
 44: /usr/share/vim/vim80/plugin/logiPat.vim                                                  
 45: /usr/share/vim/vim80/plugin/manpager.vim                                                 
 46: /usr/share/vim/vim80/plugin/matchparen.vim                                               
 47: /usr/share/vim/vim80/plugin/netrwPlugin.vim        
 48: /usr/share/vim/vim80/plugin/rrhelper.vim                                                 
 49: /usr/share/vim/vim80/plugin/spellfile.vim                                                
 50: /usr/share/vim/vim80/plugin/tarPlugin.vim                                                
 51: /usr/share/vim/vim80/plugin/tohtml.vim                                                   
 52: /usr/share/vim/vim80/plugin/vimballPlugin.vim                                            
 53: /usr/share/vim/vim80/plugin/zipPlugin.vim                                                
 54: ~/.vim/bundle/syntastic/autoload/syntastic/log.vim                                       
  • Some info that will certainly be needed to answer this is :scriptnames, that will tell you (and us) what syntax files have been loaded. – grochmal Mar 30 '17 at 0:56
  • @grochmal I added this information. – pfnuesel Mar 30 '17 at 6:28
  • check your indent settings. Looks like cindent or something similar is on. also try to come up with a minimal reproducible example, that does not include all your plugins. – Christian Brabandt Mar 30 '17 at 6:38
  • @ChristianBrabandt Yes, cindent is on. Is that a problem? – pfnuesel Mar 30 '17 at 7:05
  • @pfnuesel apparently yes. You don't want C like indenting in your text document, do you? – Christian Brabandt Mar 30 '17 at 9:04
2

Before I was using

set cindent

in my .vimrc. If I understand correctly, this turns on cindent for all filetypes. If I do not specify, it will only be turned on for cpp files, which is what I want. So removing set cindent from my .vimrc did the trick.

  • 'smartindent' is a bit, well smarter when it comes to indenting. You may give that a try as well. – Tumbler41 Mar 30 '17 at 16:12
  • I turned off smartindent at some point, can't remember the reason though. I might give it a try again. So far I wasn't very lucky with indenting in vim. – pfnuesel Mar 30 '17 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.