" For compatibility's sake, all defaults that are different between Vim and " Neovim are excplicity specified again. " Minimal version wit NO PLUGIN " look and feel set t_Co=256 set background=dark color elflord if has("gui_running") silent! set guifont=PragmataPro:h14 endif " Basics " ====== set nocompatible scriptencoding utf-8 filetype on syntax on set showmode set showcmd set rnu set ru set nu set cursorline autocmd InsertLeave,WinEnter,FocusGained * :setlocal number relativenumber autocmd InsertEnter,WinLeave,FocusLost * :setlocal number norelativenumber set backspace=indent,eol,start " Backspace for dummies set showmatch " Show matching brackets/parenthesis set smartcase " Case sensitive when uppercase present set incsearch " Find as you type search set hlsearch " Highlight search terms set wildmenu " Show list instead of just completing set wildmode=list:longest,full " Command completion, list matches, then longest common part, then all. set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too set scrolljump=5 " Lines to scroll when cursor leaves screen set scrolloff=3 " Minimum lines to keep above and below cursor set nolist " show white space set nofoldenable " disable folding set splitbelow set splitright " set synmaxcol=2048 set ttyfast " use fast terminal set ts=4 sts=4 sw=4 expandtab "set tab to space, width 4 " Status Line " =========== set laststatus=2 set statusline=\ %<%f\ " Filename set statusline+=%w%h%m%r " Options set statusline+=\ [%{&ff}/%Y] " Filetype set statusline+=\ [%{getcwd()}] " Current dir set statusline+=%=%-14.(%l,%c%V%)\ %p%%\ " Right aligned file nav info " Misc " ==== " change cursor shape based on mode if exists('$TMUX') let &t_SI = "\Ptmux;\\]50;CursorShape=1\x7\\\" " let &t_SR = "\Ptmux;\\]50;CursorShape=2\x7\\\" let &t_EI = "\Ptmux;\\]50;CursorShape=0\x7\\\" else if $TERM_PROGRAM ==# 'iTerm.app' let &t_SI = "\]50;CursorShape=1\x7" let &t_SR = "\]50;CursorShape=2\x7" let &t_EI = "\]50;CursorShape=0\x7" endif endif "no clipboard mess set clipboard= " Key Mappings " ============ let mapleader = " " " disalbe F1 :nmap :echo :imap :echo " Edit vimrc configuration file nnoremap ve :e $MYVIMRC " " Reload vimrc configuration file nnoremap vr :source $MYVIMRC " Wrapped lines goes down/up to next row, rather than next line in file. nnoremap j gj nnoremap k gk " Easier moving in tabs and windows map j_ map k_ map l_ map h_ "Emacs-style movement keys for command line :cnoremap :cnoremap :cnoremap :cnoremap :cnoremap :cnoremap :cnoremap :cnoremap b :cnoremap f :cnoremap d :cnoremap " fast toggle listchars nmap l :set list! " fast toggle spell checking nmap s :set spell! " fast toggle linewrapping nmap w :set wrap! " so that c-u can be undone by u inoremap u inoremap u " Stupid shift key fixes if has("user_commands") command! -bang -nargs=* -complete=file E e command! -bang -nargs=* -complete=file W w command! -bang -nargs=* -complete=file Wq wq command! -bang -nargs=* -complete=file WQ wq command! -bang Wa wa command! -bang WA wa command! -bang Q q command! -bang QA qa command! -bang Qa qa endif " Yank from the cursor to the end of the line, to be consistent with C and D. nnoremap Y y$ " replay @q by pressing space nnoremap @q " Code folding options nmap f0 :set foldlevel=0 nmap f1 :set foldlevel=1 nmap f2 :set foldlevel=2 nmap f3 :set foldlevel=3 nmap f4 :set foldlevel=4 nmap f5 :set foldlevel=5 nmap f6 :set foldlevel=6 nmap f7 :set foldlevel=7 nmap f8 :set foldlevel=8 nmap f9 :set foldlevel=9 " Toggle search highlighting " nmap / :set invhlsearch noremap / :nohls "fast new tab nmap t :tabnew "fast buffer switch nmap n :bn nmap p :bp " Shortcuts " Change Working Directory to that of the current file cmap cwd lcd %:p:h cmap cd. lcd %:p:h " Visual shifting (does not exit Visual mode) vnoremap < >gv " For when you forget to sudo.. Really Write the file. cmap w!! w !sudo tee % >/dev/null " Some helpers to edit mode " http://vimcasts.org/e/14 cnoremap %% =expand('%:h').'/' map ew :e %% map es :sp %% map ev :vsp %% map et :tabe %% " Adjust viewports to the same size map = = " Map ff to display all lines with keyword under cursor " and ask which one to jump to nmap ff [I:let nr = input("Which one: ")exe "normal " . nr ."[\t" " Easier horizontal scrolling map zl zL map zh zH " Functions etc " ============= " Set tabstop, softtabstop and shiftwidth to the same value command! -nargs=* Stab call Stab() function! Stab() let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ') if l:tabstop > 0 let &l:sts = l:tabstop let &l:ts = l:tabstop let &l:sw = l:tabstop endif call SummarizeTabs() endfunction function! SummarizeTabs() try echohl ModeMsg echon 'tabstop='.&l:ts echon ' shiftwidth='.&l:sw echon ' softtabstop='.&l:sts if &l:et echon ' expandtab' else echon ' noexpandtab' endif finally echohl None endtry endfunction " Plugin stuff let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' if empty(glob(data_dir . '/autoload/plug.vim')) silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif " Install vim-plug if not found 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 endif call plug#begin() " List your plugins here Plug 'morhetz/gruvbox' call plug#end() silent! colo gruvbox