dotfiles/.vimrc

139 lines
2.9 KiB
VimL
Raw Normal View History

2020-04-21 12:29:05 -04:00
""""""""""""""""""""""
" __ _____ __ __ "
" \ \ / /_ _| \/ | "
" \ V / | || |\/| | "
" \_/ |___|_| |_| "
" "
""""""""""""""""""""""
set nocp
2020-04-21 13:31:21 -04:00
so ~/.vim/user/*
colorscheme desert
2020-04-21 12:29:05 -04:00
set tsr+=~/.vim/thesaurus/thesaurus-vim-en
set dict+=/usr/share/dict/words
2020-04-21 13:31:21 -04:00
set foldmethod=syntax
set foldlevelstart=5
2020-04-21 12:29:05 -04:00
2020-04-21 13:31:21 -04:00
set backspace=indent,eol ",start
2020-04-21 12:29:05 -04:00
set splitbelow
set splitright
nnoremap :W<CR> :w<CR>
set conceallevel=0
2020-04-21 13:31:21 -04:00
" Use 4 spaces
set tabstop=8 softtabstop=0 expandtab shiftwidth=8 smarttab
2020-04-21 12:29:05 -04:00
" Except for makefiles
autocmd FileType make setlocal noexpandtab
2020-04-21 13:31:21 -04:00
" Search up to / for tags file
2020-04-21 12:29:05 -04:00
set tags=./tags;/
2020-04-21 13:31:21 -04:00
" *** BINDINGS ***
2020-04-21 12:29:05 -04:00
2020-04-21 13:31:21 -04:00
" Beautful escapes
inoremap jj <Esc>l
inoremap jk <Esc>l
inoremap kj <Esc>l
2020-04-21 12:29:05 -04:00
2020-04-21 13:31:21 -04:00
" C comment
nnoremap // m`I//<Esc>``:s-////--<Cr>
2020-04-21 12:29:05 -04:00
2020-04-21 13:31:21 -04:00
" Current-file keywords
inoremap <C-J> <C-X><C-N>
2020-04-21 12:29:05 -04:00
2020-04-21 13:31:21 -04:00
" Line numbers
set number relativenumber
2020-04-21 12:29:05 -04:00
2020-04-21 13:31:21 -04:00
set ignorecase smartcase
set autoindent smartindent
2020-04-21 12:29:05 -04:00
2020-04-21 13:31:21 -04:00
"Yank to clipboard
nnoremap <C-C> "+yy
vnoremap <C-C> "+y
2020-04-21 12:29:05 -04:00
2020-04-21 13:31:21 -04:00
" List buffers
nnoremap <Leader>b :ls<CR>:b<Space>
2020-04-21 12:29:05 -04:00
nnoremap <C-I> ^
2020-04-21 13:31:21 -04:00
2020-04-21 12:29:05 -04:00
nnoremap U ~
2020-04-21 13:31:21 -04:00
nnoremap ~ U
2020-04-21 12:29:05 -04:00
" Paste last yank (not delete))
nnoremap "p "0p
" Window jumps
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
nnoremap ! :!
" Map directions to end/beginning of lines
nnoremap yl y$
nnoremap yh y^
nnoremap dl d$
nnoremap dh d^
" <C-P> will replace text after the cursor with unnamed reg contents
nnoremap <C-P> m`v$hp``y$
" Generate and display a printable version
nnoremap <Leader>PP :ha > ~/.vim.ps<CR>:!xdg-open ~/.vim.ps<CR>
vnoremap <Leader>PP :ha > ~/.vim.ps<CR>:!xdg-open ~/.vim.ps<CR>
2020-04-21 13:31:21 -04:00
" Return spelling corrections
2020-04-21 12:29:05 -04:00
iab ruetn return
iab reteun return
iab reutner return
nnoremap cw ciw
nnoremap ciw cw
2020-04-21 13:31:21 -04:00
2020-04-21 12:29:05 -04:00
" Swap current word with next
nnoremap gs "xdiwdwep"xp
" Inverted
nnoremap gb dawbP
nnoremap <Leader>gd :!git diff %<CR>
nnoremap <Leader>gD :!git diff<CR>
nnoremap <Leader>gB :!git blame %<CR>
nnoremap <Leader>gc :!git commit -m ""<Left>
nnoremap <Leader>gh :!git --help<CR>
nnoremap <Leader>gl :!git log<CR>
nnoremap <Leader>gp :!git push<CR>
nnoremap <Leader>gu :!git add -u<CR>
nnoremap <Leader>ga :!git add %<CR>
nnoremap <Leader>r :source ~/.vimrc<CR>
nnoremap <Leader>v :tabedit~/.vimrc<CR>
nnoremap <Leader>n :tabedit~/.notes<CR>
autocmd BufNewFile,BufRead * if expand('%:t') !~ '\.' | setl spell | endif
" Expand %% to the current files dir
cabbr <expr> %% expand('%:p:h')
cnoreabbrev vimc tabedit ~/.vimrc
" Skeletons "
if has ("autocmd")
augroup templates
autocmd BufNewFile *.cpp 0r ~/.vim/templates/skeleton.cpp
autocmd BufNewFile *.c 0r ~/.vim/templates/skeleton.c
autocmd BufNewFile *.sh 0r ~/.vim/templates/skeleton.sh
autocmd BufNewFile *.lisp 0r ~/.vim/templates/skeleton.lisp
autocmd BufNewFile *.py 0r ~/.vim/templates/skeleton.py
autocmd BufNewFile *.rb 0r ~/.vim/templates/skeleton.rb
autocmd BufNewFile makefile 0r ~/.vim/templates/makefile
augroup END
endif