THEAARBS vim rc

Raw

"        _
" __   _(_)_ __ ___
" \ \ / / | '_ ` _ \
"  \ V /| | | | | | |
"   \_/ |_|_| |_| |_|
"
" ~/.vimrc

let mapleader = " "
set nocompatible

" Load Pathogen for plugins
	execute pathogen#infect()
	execute pathogen#helptags()

" See relative line numbers
	set number relativenumber
	set encoding=utf-8

" Syntax highlighting
	syntax on

" Pywal colors
"	colorscheme wal
	filetype plugin on

" Enable autocompletion
	set wildmode=longest,list,full

" Better command line completion
	set wildmenu

" Highlight searches
	set hlsearch

" Redraw the screen (clears search highlight)
	map <leader>r :nohl<CR><C-L>

" Case insensitive search, except when using capital letters
	set ignorecase
	set smartcase

" Disable automatic commenting on newline
	autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o

" Delete trailing whitespace on save
	autocmd BufWritePre * %s/\s\+$//e

" Splits open at the bottom and right
	set splitbelow splitright

" Shortcutting split navigation, saving a keypress
	map <C-h> <C-w>h
	map <C-j> <C-w>j
	map <C-k> <C-w>k
	map <C-l> <C-w>l

" Goyo plugin makes text more readable when writing prose
	map <leader>f :Goyo \| set linebreak<CR>

" Spellcheck
	map <leader>v :setlocal spell! spelllang=en_us,es<CR>

" Compile document
	map <leader>c :w! \| !compiler <c-r>%<CR><CR>

" Update dwmbar when changed.
	autocmd BufWritePost *dwmbar !killall dwmbar; setsid dwmbar &

" Open corresponding .pdf/.html or preview
	map <leader>p :!opout <c-r>%<CR><CR>

" Replace all is aliased to S.
	nnoremap S :%s//<Left>

" Ensure files are read as intended
	let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
	autocmd BufRead,BufNewFile /tmp/calcurse*,~/.calcurse/notes/* set filetype=markdown
	autocmd BufRead,BufNewFile *.ms,*.me,*.mom,*.man set filetype=groff
	autocmd BufRead,BufNewFile *.tex set filetype=tex

" Readmes autowrap text
"	autocmd BufRead,BufNewFile *.md set tw=79

" Copy selected text to system clipboard (requires gvim/nvim/vim-x11 installed):
	vnoremap <C-c> "+y
	map <C-p> "+P

" Markdown shortcuts
	autocmd Filetype markdown map <F5> :w! \| :!compiler <c-r>%<CR><CR> \| :!opout <c-r>%<CR><CR>
	autocmd Filetype markdown,rmd map <leader>w yiWi[<esc>Ea](<esc>pa)
	autocmd Filetype markdown,rmd inoremap ;n ---<Enter><Enter>
	autocmd Filetype markdown,rmd inoremap ;b ****<++><Esc>F*hi
	autocmd Filetype markdown,rmd inoremap ;s ~~~~<++><Esc>F~hi
	autocmd Filetype markdown,rmd inoremap ;e **<++><Esc>F*i
	autocmd Filetype markdown,rmd inoremap ;h ====<Space><++><Esc>F=hi
	autocmd Filetype markdown,rmd inoremap ;i ![](<++>)<++><Esc>F[a
	autocmd Filetype markdown,rmd inoremap ;a [](<++>)<++><Esc>F[a
	autocmd Filetype markdown,rmd inoremap ;1 #<Space><Enter><++><Esc>kA
	autocmd Filetype markdown,rmd inoremap ;2 ##<Space><Enter><++><Esc>kA
	autocmd Filetype markdown,rmd inoremap ;3 ###<Space><Enter><++><Esc>kA
	autocmd Filetype markdown,rmd inoremap ;l --------<Enter>

" Navigating with guides
	inoremap <Space><Tab> <Esc>/<++><Enter>"_c4l
	vnoremap <Space><Tab> <Esc>/<++><Enter>"_c4l
	map <Space><Tab> <Esc>/<++><Enter>"_c4l