call plug#begin('~/.vim/plugins') Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf.vim' Plug 'jeffkreeftmeijer/vim-numbertoggle' Plug 'tpope/vim-fugitive' Plug 'airblade/vim-gitgutter' Plug 'tpope/vim-commentary' Plug 'machakann/vim-sandwich' Plug 'junegunn/goyo.vim' Plug 'aonemd/kuroi.vim' Plug 'tpope/vim-rails' Plug 'fatih/vim-go' Plug 'mattn/emmet-vim' call plug#end() set lazyredraw "lazily redraw screen while executing macros, and other commands set ttyfast "more characters will be sent to the screen for redrawing set ttimeout "time waited for key press(es) to complete... set ttimeoutlen=50 " ...makes for a faster key response set noswapfile "disable swap files set autoread "automatically read changes in the file set hidden "hide buffers instead of closing them even if they contain unwritten changes set backspace=indent,eol,start "make backspace behave properly in insert mode set clipboard=unnamedplus "use system clipboard; requires has('unnamedplus') to be 1 set wildmenu "better menu with completion in command mode set wildmode=longest:full,full set completeopt=longest,menuone,preview "better insert mode completions set nowrap "disable soft wrap for lines set scrolloff=2 "always show 2 lines above/below the cursor set showcmd "display incomplete commands set laststatus=2 "always display the status bar set number "display line numbers set cursorline "highlight current line set colorcolumn=81 "display text width column set splitbelow "vertical splits will be at the bottom set splitright "horizontal splits will be to the right set autoindent "always set autoindenting on set formatoptions-=cro "disable auto comments on new lines set tabstop=2 shiftwidth=2 softtabstop=2 expandtab "use two spaces for indentation set incsearch "incremental search highlight set ignorecase "searches are case insensitive... set smartcase " ..unless they contain at least one capital letter set hlsearch "highlight search patterns autocmd! FileType c setlocal ts=4 sts=4 sw=4 noexpandtab autocmd! FileType java setlocal ts=4 sts=4 sw=4 expandtab autocmd! FileType make setlocal ts=8 sts=8 sw=8 noexpandtab set t_Co=256 "enable 256 colors set background=dark colorscheme kuroi "status line: modifiedflag, charcount, filepercent, filepath set statusline=%=%m\ %c\ %P\ %f "remove current line highlight in unfocused window au VimEnter,WinEnter,BufWinEnter,FocusGained,CmdwinEnter * set cul au WinLeave,FocusLost,CmdwinLeave * set nocul " "remove trailing whitespace on save autocmd! BufWritePre * :%s/\s\+$//e "The Leader let mapleader="\" nnoremap ! :! nnoremap w :w "replace the word under cursor nnoremap * :%s/\<\>//g "toggle showing hidden characters nnoremap s :set nolist! "toggle spell checking nnoremap ss :setlocal spell! "toggle RTL mode nnoremap l :set rl! "override system files by typing :w!! cnoremap w!! %!sudo tee > /dev/null % "remove search highlight nmap q :nohlsearch "move lines around nnoremap k :m-2== nnoremap j :m+== xnoremap k :m-2gv=gv xnoremap j :m'>+gv=gv "keep text selected after indentation vnoremap < >gv "fzf nnoremap p :FZF nnoremap o :Lines nnoremap t :Tags nnoremap r :Buffers nnoremap \ :Ag nnoremap \| :Ag :cw "Ctags set tags+=.git/tags nnoremap ct :!ctags -Rf .git/tags --tag-relative --extra=+f --exclude=.git,pkg --languages=-sql "GitGutter nnoremap :GitGutterNextHunk nnoremap :GitGutterPrevHunk nnoremap :GitGutterUndoHunk nnoremap B :enew nnoremap :bnext nnoremap :bprevious nnoremap bq :bp bd! # nnoremap ba :bufdo bd! "cycle between last two open buffers nnoremap "netrw let g:netrw_banner=0 let g:netrw_winsize=20 let g:netrw_liststyle=3 let g:netrw_localrmdir='rm -r' nnoremap n :Lexplore "move to the split in the direction shown, or create a new split nnoremap :call WinMove('h') nnoremap :call WinMove('j') nnoremap :call WinMove('k') nnoremap :call WinMove('l') function! WinMove(key) let t:curwin = winnr() exec "wincmd ".a:key if (t:curwin == winnr()) if (match(a:key,'[jk]')) wincmd v else wincmd s endif exec "wincmd ".a:key endif endfunction "Goyo nnoremap g :Goyo if !exists('*s:goyo_leave') function s:goyo_leave() source $MYVIMRC endfunction endif autocmd! User GoyoLeave nested call goyo_leave()