]> code.delx.au - dotfiles/commitdiff
Greatly improved Vim's indenting settings
authorJames Bunton <jamesbunton@delx.net.au>
Tue, 1 Apr 2008 06:46:41 +0000 (17:46 +1100)
committerJames Bunton <jamesbunton@delx.net.au>
Tue, 1 Apr 2008 06:46:41 +0000 (17:46 +1100)
 * smartindent shouldn't always be on, especially for text files, etc
 * filetype indent on turns on good indenting more most stuff by itself
 * bibtex is not like C! Fall back to smartindent
 * Objective C doesn't work right with cindent, so fall back to smartindent

.vim/filetypes.vim
.vim/indent.vim

index 72be877a7510b0b6e88ff444b5764caabc813773..2118c16382478138ebb690627442b0aa96fb9816 100644 (file)
@@ -1,4 +1,8 @@
-" Make vim aware of filetypes
+" Make vim aware of filetypes, this loads files in
+" vimdir/{ftplugin,indent}/lang.vim 
+" where vimdir is /usr/share/vim/vimXX/ or ~/.vim/
+" The intention is for vim to set up sensible indentation rules and other
+" settings depending on the filetype. 
 filetype plugin indent on
 
 " Pick up some filetypes from their extensions
@@ -6,10 +10,12 @@ autocmd BufNewFile,BufRead *.txt setlocal ft=text
 autocmd BufNewFile,BufRead mutt* setlocal ft=mail
 autocmd BufNewFile,BufRead *.tex setlocal ft=tex
 
-" Set options based on filetypes
-autocmd FileType text setlocal textwidth=78 nosmartindent
-autocmd FileType mail setlocal textwidth=78 nosmartindent
-autocmd FileType tex setlocal textwidth=78 nosmartindent
+" Set options based on filetypes, overriding the filetype plugin/indent options
+autocmd FileType text setlocal wrap
+autocmd FileType bib setlocal textwidth=78 nocindent smartindent
+autocmd FileType mail setlocal textwidth=78
+autocmd FileType tex setlocal wrap showbreak=>\ \ \ \ \ \ \  
+autocmd FileType objc setlocal textwidth=78 nocindent smartindent
 
 " Don't automatically continue comments on new lines
 """autocmd BufNewFile,BufRead * setlocal formatoptions-=r
index b5c6667d0964b80ab288f4f4dd3f402b1008f9db..d8976ba8ff4eba8cccbe2a0f7fe3c25f60289d7a 100644 (file)
@@ -4,10 +4,6 @@
 set autoindent
 " Keep indentation structure (tabs, spaces, etc) when autoindenting.
 set copyindent
-" Automatically indent new lines after specific keywords or braces
-set smartindent
-" Don't jump to the start of a line when typing #
-inoremap # X<c-h>#
 
 " Tab stuff
 " Size of a \t