"__ _(_)_ __ ___ _ __ ___ "\ \ / / | '_ ` _ \| '__/ __| " \ V /| | | | | | | | | (__ " \_/ |_|_| |_| |_|_| \___| "sources defaults if available if filereadable(expand('$VIMRUNTIME/defaults.vim')) unlet! g:skip_defaults_vim source $VIMRUNTIME/defaults.vim endif "plugins (vim-plug) "------------------ "ensure vim-plug is installed on VimEnter if empty(glob('~/.vim/autoload/plug.vim')) silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif "filetype *may* interfere with certain plugins filetype off call plug#begin('~/.vim/plugged') Plug 'junegunn/vim-plug' "general "------- "quality of life Plug 'tpope/vim-surround' Plug 'tpope/vim-commentary' Plug 'tpope/vim-unimpaired' Plug 'tpope/vim-rsi' Plug 'tpope/vim-eunuch' Plug 'tpope/vim-repeat' Plug 'editorconfig/editorconfig-vim' "git Plug 'tpope/vim-fugitive' "visual Plug 'flazz/vim-colorschemes' "linting Plug 'w0rp/ale' "language/ft specific "-------------------- "javascript/css/html Plug 'pangloss/vim-javascript' Plug 'mattn/emmet-vim' "go Plug 'fatih/vim-go' "md Plug 'godlygeek/tabular' Plug 'plasticboy/vim-markdown' "toml Plug 'cespare/vim-toml' call plug#end() "plugin settings "--------------- "netrw let g:netrw_banner = 0 let g:netrw_winsize = 24 let g:netrw_liststyle = 3 let g:netrw_preview = 1 let g:netrw_alto = 0 let g:netrw_usetab = 1 let g:NetrwIsOpen = 0 "for toggle function "ale let g:ale_linters = { \ 'javascript': ['standard'], \ 'markdown': ['mdl', 'write-good'] \} let g:ale_fixers = { \ '*': ['remove_trailing_lines', 'trim_whitespace'], \ 'javascript': ['standard'], \ 'markdown': ['prettier'] \} let g:ale_sign_error = '->' let g:ale_sign_warning = '--' " let g:ale_lint_on_save = 1 " let g:ale_fix_on_save = 1 "md let g:vim_markdown_folding_disabled = 1 " colorschemes " colorscheme 1989 " colorscheme PaperColor " colorscheme gruvbox " colorscheme jellybeans " colorscheme molokai " colorscheme Benokai " colorscheme Monokai " colorscheme badwolf " colorscheme wombat256 " colorscheme yuejiu " colorscheme wargrey " colorscheme Tomorrow-Night-Bright " colorscheme monokai-phoenix "general settings "---------------- "encoding/format set encoding=utf-8 set fileformats=unix,dos,mac "file/buffer set autoread set autowrite set confirm "display set background=dark set number set wrap set listchars=tab:→\ ,extends:›,precedes:‹,nbsp:·,trail:·,eol:¬ set list set foldmethod=marker set lazyredraw set regexpengine=1 set redrawtime=10000 "tab/indent set tabstop=4 set softtabstop=4 set shiftwidth=4 set expandtab set autoindent "status bar set showcmd set wildmenu set ruler set laststatus=2 "search set incsearch set hlsearch set ignorecase set smartcase "cursor behaviour set virtualedit=block set backspace=indent,eol,start set showmatch set scrolloff=2 set sidescrolloff=8 "input/timeout set esckeys set timeoutlen=1000 "for mappings set ttimeoutlen=20 "for keycodes "window behaviour (ltr) set splitbelow set splitright "undo/bkup dirs set undofile set undodir=~/.vim/.undo//,/tmp// set backupdir=~/.vim/.backup//,/tmp// set directory=~/.vim/.swap//,/tmp// "leader key let mapleader=' ' "normal/visual mode keybinds "--------------------------- "paste and search nnoremap :let @/ = "" nnoremap p :set invpaste "toggles nnoremap lb :call ToggleLineBreak() nnoremap wr :call ToggleWrap() nnoremap cc :call ToggleColorColumn() "dates nnoremap ts "=strftime("%F %T%z") nnoremap dt :r !date "rc files nnoremap rc :vsplit $MYVIMRC nnoremap so :source $MYVIMRC "formatting tools nnoremap =j :%!python -m json.tool "plugin keybinds nnoremap e :call ToggleNetrw() nnoremap at :ALEToggle "insert mode keybinds/abbreviations "-------------------- inoreabbrev #!! "#!/usr/bin/env" "custom commands "--------------- "common typos and abbreviations cnoremap w!! w !sudo tee % > /dev/null command! W w !sudo tee % > /dev/null command! Trim %s/\s\+$// command! Q q command! WQ wq command! Q1 q! "function calls command! -nargs=+ SearchGoogle call SearchGoogle(join([])) "general functions "----------------- "toggle functions function! ToggleColorColumn() if &cc == '' set cc=80 else set cc= endif endfunction function! ToggleLineBreak() if &lbr == '' set fo+=t "Autowraps text with textwidth set fo-=l "Wraps long lines in --insert-- mode set lbr else set fo-=t set fo+=l set lbr! endif endfunction function! ToggleWrap() if &wrap == '' set wrap else set nowrap endif endfunction function! ToggleNetrw() "make netrw toggleable if g:NetrwIsOpen let i = bufnr("$") while (i >= 1) if (getbufvar(i, "&filetype") == "netrw") silent exe "bwipeout " . i endif let i-=1 endwhile let g:NetrwIsOpen=0 else let g:NetrwIsOpen=1 silent Lexplore endif endfunction "search functions function! SearchGoogle(string) let l:google = "https://www.google.com/search?q=" let l:browser = "xdg-open >/dev/null 2>/dev/null" let l:query = substitute(join(split(a:string),"+"),'"',"","g") execute "!" l:browser . "\ " . l:google . l:query endfunction "syntax/filetype "--------------- syntax enable filetype plugin indent on runtime macros/matchit.vim "gui settings "------------ if has("gui_running") set guioptions -=m set guioptions -=T if has("gui_gtk2") set guifont=Inconsolata\ 12 elseif has("gui_macvim") set guifont=Menlo\ Regular:h14 elseif has("gui_win32") set guifont=Consolas:h10 endif endif "win32 settings "-------------- if has('win32') endif "auto commands "------------- if has("autocmd") "global augroup global autocmd! "keep equal proportions when windows resized autocmd VimResized * wincmd = "save cursor position in a file autocmd BufReadPost * if line("'\"") > 1 && line("'\"") \ <= line("$") | exe "normal! g'\"" | endif augroup END "language/filetype augroup languages autocmd! autocmd BufNewFile,BufRead *bash* set syntax=sh autocmd FileType python xnoremap r :'<,'>:w !python3 autocmd FileType go set noexpandtab autocmd FileType html :syntax sync fromstart autocmd FileType html,javascript,css,json,yaml,sh \ setlocal ts=2 sts=2 sw=2 expandtab autocmd BufRead,BufNewFile *.md setlocal spell augroup END endif