" designed for vim 8+ (and inspired by rwxrob) " https://github.com/starr-dusT/dotfiles """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " general """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set autowrite " automatically write files on close " tabs and spaces and stuff set tabstop=4 set softtabstop=4 set shiftwidth=4 set expandtab " undos set undodir="~/.vim/undodir" set undofile " map leader to Space let mapleader = " " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " ui """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" syntax enable set number set colorcolumn=79 set updatetime=50 set scrolloff=8 set smartindent set incsearch " hilight search matches while typing """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " wildmenu """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " ignore compiled files set wildignore=*.o,*~,*.pyc if has("win16") || has("win32") set wildignore+=.git\*,.hg\*,.svn\* else set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store endif " enable fuzzy finding in the vim command line set path=$PWD/** set nowildmenu set wildmode=list:full """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " netrw """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let g:netrw_banner = 0 " disable dumb banner " use l and h for up/down dir augroup netrw_setup | au! au FileType netrw nmap l au FileType netrw nmap h - augroup END map e :Ex " open explorer """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " marks """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " allow only global marks noremap ' "'".toupper(nr2char(getchar())) noremap m "m".toupper(nr2char(getchar())) sunmap ' sunmap m nnoremap ' :call ListSelect("marks", "'") " list jumps/marks map md :delmarks A-Z0-9 " clear marks """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " grep """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set grepprg=grep\ -snH\ $* " use system grep command! -nargs=+ -complete=file_in_path -bar Grep cgetexpr Grep() command! -nargs=+ -complete=file_in_path -bar LGrep lgetexpr Grep() " open quickfix augroup quickfix autocmd! autocmd QuickFixCmdPost cgetexpr cwindow autocmd QuickFixCmdPost lgetexpr lwindow augroup END " grep into quickfix/location list map fq :Grep **/* map fl :LGrep **/* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " misc keys """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " open help with word under cursor map oh :execute "help " . expand("") " move between splits with hjkl map j map k map h map l " find map ff :find * " change directories map cc :cd map cd :cd ~/.local/share/chezmoi " open common files map ov :e ~/.local/share/chezmoi/home/dot_vimrc " functions keys map :set number! :set relativenumber! map :set list! map :set cursorline! map :set spell! " better use of arrow keys, number increment/decrement nnoremap nnoremap """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " helpers """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " display and select from a list of marks and jumps " https://vi.stackexchange.com/a/42965 " function! ListSelect(command, jump) execute a:command echohl Question echo "Enter mark (ESC to cancel): " echohl NONE let mark = toupper(nr2char(getchar())) redraw if mark !=# "\e" try execute "normal! g" .. a:jump .. mark catch echohl ErrorMsg echo substitute(v:exception, "^Vim(.*):", "", "") echohl NONE endtry endif endfunction " better grep wrapper " https://gist.github.com/romainl/56f0c28ef953ffc157f36cc495947ab3 " function! Grep(...) return system(join([&grepprg] + [expandcmd(join(a:000, ' '))], ' ')) endfunction