Skip to content

Instantly share code, notes, and snippets.

@cskeppstedt
Created December 13, 2016 08:41
Show Gist options
  • Save cskeppstedt/93d0c250f5c30b02e575c5ca4bcfb291 to your computer and use it in GitHub Desktop.
Save cskeppstedt/93d0c250f5c30b02e575c5ca4bcfb291 to your computer and use it in GitHub Desktop.
My personal .vimrc in its current state
syntax on
set number
set numberwidth=5
set autoindent
set nowrap
set backspace=indent,eol,start whichwrap+=<,>,[,]
set laststatus=2
" LEADER key mapping
let mapleader = "\<Space>"
" disable backup files
set nobackup
set writebackup
set nowb
set noswapfile
" tabs
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
" searching
set ignorecase
set smartcase
set gdefault
set incsearch
set hlsearch
" text formatting
set formatoptions=qrn1
set scrolloff=5
set sidescrolloff=1
" dont show preview window on omnicomplete
set completeopt-=preview
" yank, deletes, etc. are copied to clipboard
set clipboard=unnamed
" horizontal cursor highlight
" set cursorline
" indent visual block
:vnoremap < <gv
:vnoremap > >gv
" Move visual block (remove gv= to ditch autoindent)
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" learn-mode: disable arrow keys
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
nnoremap j gj
nnoremap k gk
" menu on completion
set wildmenu
set foldmethod=marker
" highlight wildmenu ctermbg=3 ctermfg=0
hi wildmenu term=standout ctermfg=0 ctermbg=3 guifg=#000000 guibg=#ffd700
hi Todo term=standout guifg=#ffffff guibg=#1248d1
hi Folded guibg=black
" set statusline=%<%f%h%m%r%=\ %l,%c%V\ %P
" GUI options
set guifont=Source\ Code\ Pro\ Light:h12
" - hide scrollbars
set guioptions-=r
set guioptions-=R
set guioptions-=l
set guioptions-=L
set guioptions-=b
" enable scrolling/selecting with mouse in tmux
set mouse=a
" disable bell
set noerrorbells
set novisualbell
set t_vb=
autocmd! GUIEnter * set vb t_vb=
" turn off key delay
set ttimeoutlen=0
" Fast editing and reloading of vimrc configs
map <leader>r :e! ~/.vimrc<cr>
autocmd! bufwritepost vimrc source ~/.vimrc
" hotkey for saving the file
nnoremap <Leader>w :w<CR>
" hotkey for toggling syntastic (linting)
" nnoremap <Leader>t :SyntasticToggleMode<CR>
" Hotkey to remove trailing whitespace
:nnoremap <silent> <leader>s :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" hotkeys to resize panes
" nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
nnoremap <silent> <Leader>h :vertical resize -5<cr>
nnoremap <silent> <Leader>j :resize +5<cr>
nnoremap <silent> <Leader>k :resize -5<cr>
nnoremap <silent> <Leader>l :vertical resize +5<cr>
" Remove highlighting, e.g. after search
nnoremap <silent> <Leader><Esc> :noh<cr>
" Select recently pasted text (similar to gv - select recently selected text)
nnoremap gp `[v`]
" Hotkey for omnicomplete (ctrl+space)
inoremap <C-Space> <C-x><C-o>
inoremap <C-@> <C-Space>
" Hotkey for saving
:map <C-S> :w<CR> " normal mode
:inoremap <C-S> <C-O>:w<CR> " insert mode (returns to insert)
vmap <C-S> <Esc>:w<CR>gv " preserve selection when in selection mode
" Search for current visual selection
vnoremap // y/<C-R>"<CR>
" Ack! versions of searches
vnoremap <silent> <Leader>// y/<C-R>"<CR>:Ack! <C-R>"<CR>
nnoremap <silent> <Leader>* viwy/<C-R>"<CR>:Ack! <C-R>"<CR>
" Turn persistent undo on
try
set undodir=~/.vim_runtime/temp_dirs/undodir
set undofile
catch
endtry
" Splitting right and down feels more natural
set splitbelow
set splitright
" filetype mappings
au BufNewFile,BufRead *.es6 set filetype=javascript
" helpers
function! StrTrim(txt)
return substitute(a:txt, '^\n*\s*\(.\{-}\)\n*\s*$', '\1', '')
endfunction
"NeoBundle Scripts-----------------------------
let g:neobundle#install_process_timeout = 1500
if has('vim_starting')
set nocompatible " Be iMproved
" Required:
set runtimepath+=/Users/chris.skeppstedt/.vim/bundle/neobundle.vim/
endif
" Required:
call neobundle#begin(expand('/Users/chris.skeppstedt/.vim/bundle'))
" Let NeoBundle manage NeoBundle
" Required:
NeoBundleFetch 'Shougo/neobundle.vim'
" Add or remove your Bundles here:
" NeoBundle 'cskeppstedt/strange'
" NeoBundle 'digitaltoad/vim-jade'
" NeoBundle 'guns/xterm-color-table.vim'
" NeoBundle 'junegunn/limelight.vim'
" NeoBundle 'junegunn/seoul256.vim'
" NeoBundle 'junegunn/vim-easy-align'
" NeoBundle 'mhartington/oceanic-next'
" NeoBundle 'mtscout6/vim-cjsx'
" NeoBundle 'mxw/vim-jsx'
" NeoBundle 'vim-scripts/peaksea'
" NeoBundle 'altercation/vim-colors-solarized'
" NeoBundle 'MarcWeber/vim-addon-mw-utils' " dependency of garbas/vim-snipmat
NeoBundle 'jacoborus/tender'
NeoBundle 'jonathanfilip/vim-lucius'
NeoBundle 'morhetz/gruvbox'
NeoBundle 'w0ng/vim-hybrid'
NeoBundle 'cocopon/lightline-hybrid.vim'
NeoBundle 'ajh17/Spacegray.vim'
NeoBundle 'fatih/vim-nginx'
NeoBundle 'vim-material-theme'
"NeoBundle 'amix/vim-zenroom2'
NeoBundle 'bronson/vim-trailing-whitespace'
NeoBundle 'editorconfig/editorconfig-vim'
NeoBundle 'ervandew/supertab'
NeoBundle 'itchyny/lightline.vim'
NeoBundle 'jiangmiao/auto-pairs'
NeoBundle 'jistr/vim-nerdtree-tabs'
"NeoBundle 'junegunn/goyo.vim' " dependency of amix/vim-zenroom2
NeoBundle 'kchmck/vim-coffee-script'
NeoBundle 'kien/ctrlp.vim'
NeoBundle 'SirVer/ultisnips'
NeoBundle 'cskeppstedt/my-vim-ultisnips'
NeoBundle 'leafgarland/typescript-vim'
NeoBundle 'mileszs/ack.vim'
NeoBundle 'mustache/vim-mustache-handlebars'
NeoBundle 'pangloss/vim-javascript'
NeoBundle 'maxmellon/vim-jsx-pretty'
NeoBundle 'neomake/neomake'
NeoBundle 'othree/javascript-libraries-syntax.vim'
NeoBundle 'othree/es.next.syntax.vim'
NeoBundle 'scrooloose/NERDCommenter'
NeoBundle 'scrooloose/nerdtree'
" NeoBundle 'scrooloose/syntastic'
NeoBundle 'terryma/vim-multiple-cursors'
NeoBundle 'tpope/vim-commentary'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'tpope/vim-surround'
" NeoBundle 'tomtom/tlib_vim' " dependency of garbas/vim-snipmate
NeoBundle 'chriskempson/base16-vim'
NeoBundle 'Valloric/YouCompleteMe', {
\ 'build' : {
\ 'mac' : './install.py',
\ 'unix' : './install.py',
\ 'windows' : 'install.py',
\ 'cygwin' : './install.py'
\ }
\ }
" Required:
call neobundle#end()
" Required:
filetype plugin indent on
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck
"End NeoBundle Scripts-------------------------
" let the Ack plugin use the_silver_surfer
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" shortcut 'z' for Goyo mode
" nnoremap <silent> <leader>z :Goyo 110x85%<cr>
" run scripts when entering/leaving Goyo
" autocmd! User GoyoEnter nested call <SID>goyo_enter()
" autocmd! User GoyoLeave nested call <SID>goyo_leave()
" function! s:goyo_enter()
" silent !tmux set status off
" set noshowmode
" set noshowcmd
" set wrap
" endfunction
" function! s:goyo_leave()
" silent !tmux set status on
" set showmode
" set showcmd
" set nowrap
" endfunction
" Color name (:help cterm-colors) or ANSI code
" let g:limelight_conceal_ctermfg = 'gray'
" let g:limelight_conceal_ctermfg = 240
"
" Color name (:help gui-colors) or RGB color
" let g:limelight_conceal_guifg = 'DarkGray'
" let g:limelight_conceal_guifg = '#777777'
"
" Default: 0.5
let g:limelight_default_coefficient = 0.7
"
" Number of preceding/following paragraphs to include (default: 0)
let g:limelight_paragraph_span = 1
" start NERDtree if no files were specified
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" close vim if NERDtree is the only open buffer
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" NEERDTree bindings
nmap <F3> :NERDTreeToggle<CR>
nmap <F4> :NERDTreeFind<CR>
function! NERDTreeMapRefreshRoot()
call nerdtree#putCursorInTreeWin()
call nerdtree#invokeKeyMap('R')
" Go back to previous window.
wincmd p
endfunction
highlight NERDTreeOpenable ctermfg=4
highlight NERDTreeClosable ctermfg=4
" CtrlP
nnoremap <Leader>r :CtrlPClearCache<cr>call s:UpdateNERDTree()<cr>
" recommended syntastic settings
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
nmap <F5> :lnext
nmap <F6> :lprev
" let g:syntastic_always_populate_loc_list = 1
" let g:syntastic_auto_loc_list = 0
" let g:syntastic_check_on_open = 0
" let g:syntastic_check_on_wq = 0
" let g:syntastic_html_tidy_exec = 'tidy5'
" autocmd FileType javascript let b:syntastic_checkers = findfile('.eslintrc', '.;') != '' ? ['eslint'] : ['standard']
" let g:syntastic_javascript_eslint_exe = StrTrim(system('npm-which eslint'))
" let g:syntastic_javascript_checkers = ['eslint']
" let g:syntastic_ruby_checkers = ['rubocop']
" let g:syntastic_html_tidy_ignore_errors = [
" \ 'plain text isn''t allowed in <head> elements',
" \ '<base> escaping malformed URI reference',
" \ 'discarding unexpected <body>',
" \ '<script> escaping malformed URI reference',
" \ '</head> isn''t allowed in <body> elements'
" \ ]
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
vmap <Enter> <Plug>(EasyAlign)
"
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" ctrlp
let g:ctrlp_custom_ignore = '\v[\/](node_modules|dist)|(\.(swp|git))$'
" YouCompleteMe
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_seed_identifiers_with_syntax = 1
" vim-jsx-pretty
augroup VimJsxPretty
autocmd!
autocmd VimEnter *.js,*.jsx highlight jsNoise ctermfg=197 cterm=bold guifg=#F92672 gui=bold
autocmd VimEnter *.js,*.jsx highlight jsArrowFunction ctermfg=197 cterm=bold guifg=#F92672 gui=bold
autocmd VimEnter *.js,*.jsx highlight jsObjectBraces ctermfg=197 cterm=bold guifg=#F92672 gui=bold
autocmd VimEnter *.js,*.jsx highlight jsFuncBraces ctermfg=118 guifg=#A6E22E
autocmd VimEnter *.js,*.jsx highlight jsFuncCall ctermfg=228 guifg=#A6A5AE
autocmd VimEnter *.js,*.jsx highlight jsBrackets cterm=bold gui=bold
augroup END
" hack to make the gutter (lint/hint/syntasitc warnings) have the same bg as the theme
hi clear SignColumn
hi TabLine term=bold cterm=bold ctermbg=7 ctermfg=235
hi Title ctermfg=244 ctermbg=15 term=bold cterm=bold
hi TabLineFill term=NONE cterm=NONE ctermbg=7 ctermfg=7
hi TabLineSel term=bold cterm=bold ctermbg=235 ctermfg=15
" lightline
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'filename' ] ],
\ 'right': [ [ 'lineinfo' ], ['percent'], [ 'filetype' ] ]
\ },
\ 'mode_map': {
\ 'n' : 'N',
\ 'i' : 'I',
\ 'R' : 'R',
\ 'v' : 'V',
\ 'V' : 'L'
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ },
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
function! LightLineModified()
return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! LightLineFilename()
let fname = expand('%')
return fname =~ '__Gundo\|NERD_tree' ? '' :
\ ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ ('' != fname ? fname : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
endfunction
function! LightLineFugitive()
try
if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*fugitive#head')
let mark = '' " edit here for cool mark
let _ = fugitive#head()
return strlen(_) ? mark._ : ''
endif
catch
endtry
return ''
endfunction
function! LightLineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : ''
endfunction
function! LightLineMode()
let fname = expand('%:t')
return fname == '__Tagbar__' ? 'Tagbar' :
\ fname =~ 'NERD_tree' ? 'NERDTree' :
\ &ft == 'unite' ? 'Unite' :
\ &ft == 'vimfiler' ? 'VimFiler' :
\ &ft == 'vimshell' ? 'VimShell' :
\ winwidth(0) > 60 ? lightline#mode() : ''
endfunction
let g:tagbar_status_func = 'TagbarStatusFunc'
function! TagbarStatusFunc(current, sort, fname, ...) abort
let g:lightline.fname = a:fname
return lightline#statusline(0)
endfunction
" augroup AutoSyntastic
" autocmd!
" autocmd BufWritePost *.c,*.cpp call s:syntastic()
" augroup END
" function! s:syntastic()
" SyntasticCheck
" call lightline#update()
" endfunction
let g:unite_force_overwrite_statusline = 0
let g:vimfiler_force_overwrite_statusline = 0
let g:vimshell_force_overwrite_statusline = 0
" ultisnips
let g:UltiSnipsExpandTrigger="<c-space>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" AutoPair
nnoremap <Leader>a :call AutoPairsToggle()<CR>
" autocmd BufNewFile,BufRead * :call AutoPairsToggle()
if has("gui_running")
" gui/mvim specific overrides
" set guifont=Bitstream\ Vera\ Sans\ Mono:h11
set guifont=Fira\ Code:h11
set t_Co=256
" colorscheme gruvbox
" let g:lightline.colorscheme = 'gruvbox'
" set background=dark
" let g:hybrid_reduced_contrast = 1
" colorscheme hybrid
" let g:lightline.colorscheme = 'seoul256'
" let g:lucius_style = 'light'
" let g:lucius_contrast = 'low'
" let g:lucius_contrast_bg = 'normal'
" colorscheme lucius
"let g:lightline.colorscheme = 'Tomorrow_Night_Eighties'
let g:lightline.colorscheme = 'materialtheme'
colorscheme materialtheme
else
" set background=dark
" let base16colorspace=256
" colorscheme base16-tomorrow
" let g:lightline.colorscheme = 'tender'
" colorscheme tender
let g:hybrid_custom_term_colors = 1
let g:hybrid_reduced_contrast = 1 " Remove this line if using the default palette. colorscheme hybrid
" let g:lightline_hybrid_style = 'plain'
let g:lightline.colorscheme = 'hybrid'
colorscheme hybrid
endif
" neomake
let g:neomake_javascript_eslint_exe = system('PATH=$(npm bin):$PATH && which eslint | tr -d "\n"')
" let g:neomake_javascript_eslint_maker = {
" \ 'exe': StrTrim(system('npm-which eslint'))
" \ }
let g:neomake_javascript_enabled_makers = ['eslint']
" let g:neomake_verbose = 3
autocmd! BufWritePost * Neomake
nmap <Leader>lo :lopen<CR> " open location window
nmap <Leader>lc :lclose<CR> " close location window
nmap <Leader>ll :ll<CR> " go to current error/warning
nmap <Leader>ln :lnext<CR> " next error/warning
nmap <Leader>lp :lprev<CR> " previous error/warning"
" typescript
let g:typescript_compiler_binary = StrTrim(system('npm-which ntsc'))
@cskeppstedt
Copy link
Author

Some context:

  • Mac OSX, VIM 8.0 (2016 Sep 12)
  • Assumes that you have ag installed, for grepping across the project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment