This repository has been archived on 2024-09-01. You can view files and clone it, but cannot push or open issues or pull requests.
al-skel/home/.vimrc
2018-06-10 18:30:50 -07:00

70 lines
2.2 KiB
VimL

" Sane vim defaults for ArchLabs
" Arch defaults
runtime! archlinux.vim
set modeline " enable vim modelines
set clipboard^=unnamedplus " system clipboard (requires +clipboard)
set number " enable line numbers
set confirm " ask confirmation for some things, like save before quit, etc.
set wildmenu " Tab completion menu when using command mode
set expandtab " Tab key inserts spaces not tabs
set softtabstop=4 " spaces to enter for each tab
set shiftwidth=4 " amount of spaces for indentation
set shortmess+=aAcIws " Hide or shorten certain messages
" enable mouse.. sgr is better but not every term supports it
set mouse=a
if has('mouse_sgr')
set ttymouse=sgr
endif
" syntax highlighting with true colors in the terminal
syntax enable
if has('termguicolors') && $DISPLAY !=? ''
set termguicolors
" fix true colours in some terminals
if !has('nvim') && !($TERM =~? 'xterm' || &term =~? 'xterm')
let $TERM = 'xterm-256color'
let &term = 'xterm-256color'
endif
endif
" change cursor shape for different modes
if !has('nvim') && exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\e[5 q\<Esc>\\"
let &t_SR = "\<Esc>Ptmux;\<Esc>\e[4 q\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\e[2 q\<Esc>\\"
elseif !has('nvim')
let &t_SI = "\e[6 q"
let &t_SR = "\e[4 q"
let &t_EI = "\e[2 q"
endif
" paste while in insert mode
inoremap <silent><C-v> <Esc>:set paste<CR>a<C-r>+<Esc>:set nopaste<CR>a
" alt defaults
nnoremap 0 ^
nnoremap Y y$
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap <Tab> ==j
" j = gj :: k = gk while preserving numbered jumps ie. 12j or 30k
nnoremap <buffer><silent><expr>j v:count ? 'j' : 'gj'
nnoremap <buffer><silent><expr>k v:count ? 'k' : 'gk'
" Reload changes if file changed outside of vim requires autoread
augroup load_changed_file
autocmd!
autocmd FocusGained,BufEnter * if mode() !=? 'c' | checktime | endif
autocmd FileChangedShellPost * echo "Changes loaded from file"
augroup END
" when quitting a file, save the cursor position
augroup save_cursor_position
autocmd!
autocmd BufReadPost * call setpos(".", getpos("'\""))
augroup END