so $HOME/.vim/autofiletypes.vim
syntax on

"execute pathogen#infect()

set visualbell
set backup
set backupdir=~/.vimbak
set directory=~/.vimbak/swap
set viewdir=~/.vimbak/views
" Set the swap directory in here so that it doesn't clutter Dropbox updating.
let mybakvar = strftime(".%y%m%d")
let mybakvar = "set backupext=". mybakvar
execute mybakvar
set pastetoggle=<F2>
set showmode

set smarttab
set ai
set si
set title

" Turn on search increments
set incsearch
" Code folding
set foldmethod=indent
set nofoldenable
"Just turn it off by default. Check foldmethod for info.
set hidden
" Keep the undo stack hanging around as new buffers are opened
"set undofile
"This hasn't been introduced yet...wait for Vim 7.3

" Tell vim to remember certain things when we exit
"  '10 : marks will be remembered for up to 10 previously edited files
"  "100 : will save up to 100 lines for each register
"  I think the previous is incorrect...it should be <100 (I will use <1000 to save registers).
"  :20 : up to 20 lines of command-line history will be remembered
"  % : saves and restores the buffer list
"  n... : where to save the viminfo files
set viminfo='10,<1000,:20,%,n~/.viminfo

"Add an autocommand for dot typo files.
augroup typo
  autocmd BufNewFile *. !vim <afile>tex
  autocmd BufNewFile *. :q
augroup END

"Add an autocommand to save folds
augroup foldSaver
  autocmd BufWinLeave *.* mkview
  autocmd BufWinEnter *.* silent loadview
augroup END

" when we reload, tell vim to restore the cursor to the saved position
augroup JumpCursorOnEdit
 au!
 autocmd BufReadPost *
 \ if expand("<afile>:p:h") !=? $TEMP |
 \ if line("'\"") > 1 && line("'\"") <= line("$") |
 \ let JumpCursorOnEdit_foo = line("'\"") |
 \ let b:doopenfold = 1 |
 \ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
 \ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
 \ let b:doopenfold = 2 |
 \ endif |
 \ exe JumpCursorOnEdit_foo |
 \ endif |
 \ endif
 " Need to postpone using "zv" until after reading the modelines.
 autocmd BufWinEnter *
 \ if exists("b:doopenfold") |
 \ exe "normal zv" |
 \ if(b:doopenfold > 1) |
 \ exe "+".1 |
 \ endif |
 \ unlet b:doopenfold |
 \ endif
augroup END


"Sum numbers together
let g:Sumvar = 0 "put the result in global variable S
function! Sum(number)
	let g:Sumvar = g:Sumvar + a:number
	return a:number
endfunction

"Add constants together
let g:Changeconst = 0 "this is what each number is changed by
function! AddConstants(number)
	return a:number + g:Changeconst
endfunction
"handy search:
"  :%s/\d\+ \d\+ \zs\d\+/\=AddConstants(submatch(0))/
"This looks past the first two numbers and replaces the third with its new const


"Turn on the vim-latexsuite plugin
filetype plugin on
set grepprg=grep\ -nH\ $*
filetype indent on
let g:tex_flavor='latex'

nmap <F3> :TagbarToggle<CR>


"To turn off the smart quotes in vim-LaTeXsuite
let g:Tex_SmartKeyQuote = 0
"To get the \ll command compiling pdf
let g:Tex_DefaultTargetFormat = 'pdf'
"To stop Vim from opening common files in place of the working one at
"compilation
"This still doesn't work...vim-latex-suite needs to be upgraded!!
let g:Tex_CompileRule_pdf = 'pdflatex -interaction=nonstopmode -file-line-error $*'

"This will prevent that warning from showing up
let g:Tex_IgnoredWarnings = 
\"Underfull\n".
\"Overfull\n".
\"specifier changed to\n".
\"You have requested\n".
\"Missing number, treated as zero.\n".
\"There were undefined references\n".
\"Citation %.%# undefined\n".
\"Rerun to get cross-references right.\n".
\'LaTeX Font Warning:'"
let g:Tex_IgnoreLevel = 8

