+set wildmode=longest:full,full " specifies how command line completion works
+set wildignorecase " ignore case when completing file names
+
+set wildignore+=.hg,.git,.svn " Version control
+set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
+set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
+set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
+set wildignore+=*.spl " compiled spelling word lists
+set wildignore+=*.sw? " Vim swap files
+set wildignore+=*.luac " Lua byte code
+set wildignore+=*.pyc " Python byte code
+set wildignore+=*.orig " Merge resolution files
+
+" running make and jumping to errors {{{2
+set makeprg=make\ -w " print changing directories
+
+set grepformat=%f:%l:%c:%m
+set grepprg=ag\ --vimgrep\ $*
+
+" language specific {{{2
+set isfname-== " don't treat `=` as being part of filenames
+
+" various {{{2
+set virtualedit+=block " let cursor move past last char in <C-V> mode
+set virtualedit+=onemore " allow the cursor to move just past the end of the line
+if !has('nvim')
+ " viminfo defaults but save file in .cache
+ set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo
+else
+ " shada is the replacement format for viminfo
+ " this setting is probably not needed as it's most likely the default
+ " the default path is in XDG_DATA_HOME, which is fine
+ set shada='100,<50,s10,h
+endif
+
+set viewdir=$XDG_CACHE_HOME/vim/view//
+
+set sessionoptions+=unix,slash " damn windows and it's silly ways
+
+" autocmds {{{1
+" Resize splits when the window is resized {{{2
+augroup resize_splits
+ au!
+ autocmd VimResized * :tabdo wincmd =
+augroup END
+
+" Only show cursorline in the current window and in normal mode {{{2
+augroup cline
+ au!
+ au WinLeave,InsertEnter * set nocursorline
+ au WinEnter,InsertLeave * set cursorline
+augroup END
+
+" Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
+augroup ft_stdin
+ au!
+ au StdinReadPost * :set buftype=nofile
+augroup END
+
+" Jump to last known cursor position {{{2
+augroup last_loc
+ au!
+ " blacklist certain filetype
+ let blacklist = ['gitcommit']
+ autocmd BufReadPost *
+ \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
+ \ exe "normal! g`\"" |
+ \ endif
+augroup END
+
+" Check for file modifications automatically {{{2
+" (current buffer only)
+" Use :NoAutoChecktime to disable it (uses b:autochecktime)
+fun! MyAutoCheckTime()
+ " only check timestamp for normal files
+ if &buftype != '' | return | endif
+ if ! exists('b:autochecktime') || b:autochecktime
+ checktime %
+ let b:autochecktime = 1
+ endif
+endfun
+augroup MyAutoChecktime
+ au!
+ au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
+augroup END
+command! NoAutoChecktime let b:autochecktime=0
+command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
+
+" bindings {{{1
+
+" make
+function! MakeWithOpt()
+ " TODO only do this if makeprg matches make
+ " if &makeprg =~ "make"
+ let l:make_dir = ""
+ if exists("b:make_dir")
+ let l:make_dir = "-C ".b:make_dir
+ elseif exists("t:make_dir")
+ let l:make_dir = "-C ".t:make_dir
+ elseif exists("g:make_dir")
+ let l:make_dir = "-C ".g:make_dir
+ endif