filetype plugin on
filetype indent on
set autoread
set wildmenu
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
set hlsearch
set incsearch
set magic
set encoding=utf8
set ffs=unix,dos,mac
set noswapfile
set mouse=a
set path+=**

" Default to modern indenting
set autoindent
set smartindent

set expandtab
set shiftwidth=4
set tabstop=4
set softtabstop=4

" Return to last edit position when opening files
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif

" Disable highlight when <leader><cr> is pressed
map <silent> <leader><cr> :noh<cr>

" :W sudo saves the file
command W w !sudo tee % > /dev/null

" Toggle displaying special characters
map <leader><tab> :call ToggleListChars()<cr>
let g:list_chars_enabled = 0
function! ToggleListChars()
    if g:list_chars_enabled
        :set nolist
        :set listchars=eol:$
        let g:list_chars_enabled = 0
    else
        :set list
        :set listchars=tab:→\ ,space:·,nbsp:␣,trail:•,eol:¶,precedes:«,extends:»
        let g:list_chars_enabled = 1
    endif
endfunction
