dotfiles/vim/.vimrc

131 lines
2.7 KiB
VimL
Executable file

"Indent depending on filetype
filetype plugin on
set autoindent
filetype indent on
"Fix different locale settings when ssh'ing
set encoding=utf-8
"Set syntax on
syntax enable
"4 spaces instead of tabs
set tabstop=4 shiftwidth=4 softtabstop=4 expandtab
" Fold methods based on indents
" zo to open folds, zc to close
set foldmethod=indent
set foldlevel=20
" Search down into subfolders
" Provides tab-completion for all file-related tasks
set path+=**
" Display all matching files when we tab complete
set wildmenu
set backspace=2
" Vim & Tmux background color fix
set t_ut=
" Light colorscheme by default
colorscheme seagull
"Change theme depending on the time of day
let hr = (strftime('%H'))
if hr >= 19
colorscheme base16-eighties
elseif hr >= 8
colorscheme xcode
elseif hr >= 0
colorscheme base16-eighties
endif
" Terminal colors
set termguicolors
"Automatically source vimrc on save.
autocmd! bufwritepost $MYVIMRC source $MYVIMRC
"Line numbers
set number
"Changes to current directory when creating new files
set autochdir
"Higlhight search
set hls
"Search as characters are entered
set incsearch
"Line for linewrapping
set colorcolumn=80
"Remove temporary swap file
set nobackup
set noswapfile
"Wrap text instead of being on one line
set lbr
"Default Colors for CursorLine
set cursorline
highlight CursorLine cterm=none
"Activate statusbar
set laststatus=2
set statusline=\ %F\ %m%r%w\ %=\ %{hostname()}\ \ \ %{strlen(&ft)?&ft:'none'}\ %{(&bomb?\",BOM\":\"\")}\ %{&ff}\ \ %l/%L\ \ %c\ %P
"Remove trailing spaces on save
autocmd BufWritePre * :%s/\s\+$//e
"Make vim save and load the folding of the document each time it loads
"Also places the cursor in the last place that it was left
au BufWinLeave * mkview
au BufWinEnter * silent loadview
"Use pylint for python files (:make % for current file, :make * for all
"files in current directory
autocmd FileType python compiler pylint
"Netrw options
function! ToggleVExplorer()
if exists("t:expl_buf_num")
let expl_win_num = bufwinnr(t:expl_buf_num)
if expl_win_num != -1
let cur_win_nr = winnr()
exec expl_win_num . 'wincmd w'
close
exec cur_win_nr . 'wincmd w'
unlet t:expl_buf_num
else
unlet t:expl_buf_num
endif
else
exec '1wincmd w'
Vexplore
let t:expl_buf_num = bufnr("%")
endif
endfunction
let g:netrw_banner = 0
let g:netrw_winsize = -30
let g:netrw_browse_split = 4
let g:netrw_liststyle = 3
" ------------ Keybindings ----------------
"Paste mode toggle
set pastetoggle=<F2>
"Reload file
map <F5> :e <CR>
"Open netrw browser
map <silent> <C-E> :call ToggleVExplorer()<CR>
"Open quickfix window
map <F3> :copen <CR>