-autocmd BufEnter * :syntax sync fromstart " ensure every file does syntax highlighting (full)
-autocmd BufNewFile *.sh call append(0, "#!/bin/bash")
-autocmd BufNewFile *.pl call append(0, "#!/usr/bin/perl")
-autocmd BufNewFile *.py call append(0, "#!/bin/python")
+if has ("autocmd")
+ " Enable file type detection ('filetype on').
+ " Syntax of these languages is fussy over tabs Vs spaces
+ autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
+ autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
+ " Customisations based on house-style (arbitrary)
+ autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab
+ autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
+ " Treat sh correctly
+ autocmd FileType sh setlocal ts=4 sts=4 sw=4 expandtab
+ " Treat .rss files as XML
+ autocmd BufNewFile,BufRead *.rss,*.atom setfiletype xml
+
+ autocmd FileType c,cpp,slang set cindent
+ autocmd FileType c,cpp,slang set textwidth=79
+
+ autocmd BufEnter * :syntax sync fromstart " ensure every file does syntax highlighting (full)
+ autocmd BufNewFile *.sh call append(0, "#!/bin/bash")
+ autocmd BufNewFile *.pl call append(0, "#!/usr/bin/perl")
+ autocmd BufNewFile *.py call append(0, "#!/bin/python")
+
+ " When editing a file, always jump to the last known cursor position.
+ " Don't do it when the position is invalid or when inside an event handler
+ " (happens when dropping a file on gvim).
+ autocmd BufReadPost *
+ \ if line("'\"") > 0 && line("'\"") <= line("$") |
+ \ exe "normal g`\"" |
+ \ endif
+endif
+