Skip to content

Instantly share code, notes, and snippets.

@ivan-krukov ivan-krukov/.vimrc
Created Sep 20, 2017

What would you like to do?
vimrc for Vim 8
" Plugins {{{
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdcommenter'
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
Plug 'christoomey/vim-tmux-navigator'
Plug 'chriskempson/base16-vim'
Plug 'sheerun/vim-polyglot'
Plug 'fatih/vim-go'
Plug 'SirVer/ultisnips'
Plug 'scrooloose/nerdtree'
Plug 'haya14busa/incsearch.vim'
Plug 'airblade/vim-gitgutter'
Plug 'mattn/emmet-vim'
call plug#end()
" }}}
" Basic settings {{{
" no vi, only vim
set nocompatible
filetype indent plugin on
" syntax highlighting
syntax on
" allow editing mulitple unsaved files
set hidden
" Don't move cursor to start of line after multi-line jumps
set nostartofline
" }}}
" Search {{{
" Case insenstivity
set ignorecase
" Case sensitivity when using caps
set smartcase
" Ignore whitespace while diffing
set diffopt+=iwhite
" }}}
" Indentation {{{
" keep indentation
set autoindent
" Backspace over indent, end of line, start of insert
set backspace=indent,eol,start
" 4-space soft tabs
set shiftwidth=4
set softtabstop=4
set tabstop=4
set expandtab
" File-specific
augroup filetype_indent
autocmd FileType javascript setlocal shiftwidth=2 softtabstop=2 tabstop=2 expandtab
autocmd FileType html setlocal shiftwidth=2 softtabstop=2 tabstop=2 expandtab
autocmd FileType css setlocal shiftwidth=2 softtabstop=2 tabstop=2 expandtab
augroup END
" }}}
" Terminal UI {{{
" Show me as I type
set showcmd
" Show cursor location
set ruler
" Show line numbers
set number
" 2 line status area
set cmdheight=2
" Always a status line for last window
set laststatus=2
" Ask if trying to close edited file
set confirm
" Smaller timeout for commands
set timeout timeoutlen=1000 ttimeoutlen=0
" Do not expand comments to next line
set formatoptions-=r " On enter
set formatoptions-=o " On 'o'
" tab completion for menu items
set wildmenu
" be lazy
set lazyredraw
" Folding
set foldmethod=marker
" Colors
let base16colorspace=256
if filereadable(expand("~/.vimrc_background"))
let base16colorspace=256
source ~/.vimrc_background
" }}}
" Key mappings {{{
" Core mappings
let mapleader = "\<Space>"
let maplocalleader = ","
set mouse=a
" Movement
" H to go to beginning of line
xnoremap H ^
" L to go to end of line
xnoremap L $
" No join
xnoremap J j
" No doc lookup
xnoremap K k
" move vertically by visual line
nnoremap j gj
nnoremap k gk
" wrap left and right movements
set whichwrap+=<,>,h,l,[,]
" Show whitespace
nnoremap <leader>l :set list!<CR>
set listchars=tab:▸\ ,eol
" Close buffer but not split
nnoremap <leader>z :bp\|bd #<CR>
" Misc settings
" Sourcing vimrc
nnoremap <leader>ve :split $MYVIMRC<CR>
nnoremap <leader>vs :source $MYVIMRC<CR>
" }}}
" FZF {{{
nnoremap <leader>f :Files<CR>
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>a :Ag<CR>
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'TabLine'],
\ 'bg+': ['bg', 'TabLine'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
function! s:fzf_statusline()
" Override statusline as you like
highlight fzf ctermfg=white ctermbg=black
setlocal statusline=%#fzf1#\ >\ fzf
autocmd! User FzfStatusLine call <SID>fzf_statusline()
" }}}
" UltiSnips {{{
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" }}}
" NerdTree {{{
augroup NERD
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
augroup END
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let NERDTreeIgnore = ['\.pyc$', 'node_modules']
" }}}
" incsearch {{{
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
set hlsearch
let g:incsearch#auto_nohlsearch = 1
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
map * <Plug>(incsearch-nohl-*)
map # <Plug>(incsearch-nohl-#)
map g* <Plug>(incsearch-nohl-g*)
map g# <Plug>(incsearch-nohl-g#)
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.