if !exists("autocommands_loaded") let autocommands_loaded = 1 augroup filetypedetect au! BufRead,BufNewFile cupsd.conf setfiletype apache augroup END augroup C autocmd BufRead *.c set cindent augroup END endif syntax on set tabstop=4 set shiftwidth=4 " set fileencodings=ucs-bom,utf-8,latin1 function! MM() " such a line must be within the last 5 lines of a file " use ':call MM()' to call it call append(line('$'), '# vim' . ': ts=' . &ts . ' sw=' . &sw . ' filetype=' . &filetype) endfunction function ToggleHex() " save current mode let l:modified=&mod let l:oldreadonly=&readonly let &readonly=0 let l:oldmodifiable=&modifiable let &modifiable=1 if !exists("b:editHex") || !b:editHex " save old ed-mode let b:oldft=&filetype let b:oldbin=&binary " switch to bin ed-mod setlocal binary let &ft="xxd" let b:editHex=1 %!xxd else " restore let &filetype=b:oldft if !b:oldbin setlocal nobinary endif let b:editHex=0 %!xxd -r endif let &mod=l:modified let &readonly=l:oldreadonly let &modifiable=l:oldmodifiable endfunction command! -bar Hexmode call ToggleHex() " different encoding: " http://vimdoc.sourceforge.net/htmldoc/editing.html#++enc " Sometimes vim does not sync: see " http://vim.wikia.com/wiki/Fix_syntax_highlighting " To check use: :syntax sync " and see: :help :syn-sync " to get rid off it use the bummer: :syntax sync fromstart " or a little bit more moderate: :syntax sync maxlines=500