Skip to content

Instantly share code, notes, and snippets.

@cskeppstedt
Created March 13, 2016 18:06
Show Gist options
  • Save cskeppstedt/8a54275a8e8b28f9bd79 to your computer and use it in GitHub Desktop.
Save cskeppstedt/8a54275a8e8b28f9bd79 to your computer and use it in GitHub Desktop.
My current vim setup
######################################################
# Theme and general behavior
######################################################
set-option -ga update-environment ' PTTY'
set -g default-terminal "screen-256color"
# set -g status-bg black
# set -g status-fg white
set -g status-bg colour15
set -g status-fg colour235
set -g window-status-bg default
set -g window-status-fg colour249
set -g window-status-attr dim
set -g window-status-format " #40W "
# set -g window-status-current-bg default
# set -g window-status-current-fg black
set -g window-status-current-bg colour7
set -g window-status-current-fg colour235
set -g window-status-current-attr bold
set -g window-status-current-format " #40W "
#set -gw window-status-format "#I:#10W#F"
set -g status-interval 30
set -g status-left-length 100
set -g status-left ''
set -g status-right-length 100
set -g status-right '#[fg=default]%H:%M#[default]'
# set -g pane-border-fg colour0
# set -g pane-active-border-fg colour0
set -g pane-border-fg colour15
set -g pane-active-border-fg colour15
set -g mode-keys vi
setw -g mode-keys vi
set -g history-limit 10000
set -sg escape-time 0
# set -g base-index 1
# setw -g pane-base-index 1
set-option -g mouse-select-pane on
set-option -g mouse-select-window on
set-option -g mouse-resize-pane on
set-option -g mouse-utf8 on
set-window-option -g mode-mouse on
# keep mouse pressed, press y
bind-key -t vi-copy 'y' copy-pipe "pbcopy"
######################################################
# Key bindings
######################################################
#
# Summary:
#
# C-a C-k : Clears the current pane
#
# C-a d : Split window horizontally
# C-a C-d : Split window vertically
#
# C-a left : Alias C-a h : Move to the pane to the left
# C-a down : Alias C-a j : Move to the pane below
# C-a up : Alias C-a k : Move to the pane above
# C-a right : Alias C-a l : Move to the pane to the right
# C-a C-a : Move to next pane in window (rotating)
#
# C-h : Resize current pane 2 steps left
# C-j : Resize current pane 2 steps down
# C-k : Resize current pane 2 steps up
# C-l : Resize current pane 2 steps right
#
# C-a C-r : Reloads config from ~/.tmux.conf
#
# mimic GNU screen, use ctrl+a as prefix
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# clear screen
unbind C-k
bind C-k send-keys -R\; send-keys "Enter"\; display "Cleared"
# easy-to-remember split pane commands (-c to define path of new pane)
bind d split-window -h -c "#{pane_current_path}"
bind C-d split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# moving between panes with vim movement keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key Up select-pane -U
bind-key Down select-pane -D
bind-key Left select-pane -L
bind-key Right select-pane -R
bind C-a select-pane -t :.+
# resize panes with vim movement keys
bind -n C-h resize-pane -L 2
bind -n C-j resize-pane -D 2
bind -n C-k resize-pane -U 2
bind -n C-l resize-pane -R 2
######################################################
# copy text to system clipboard
######################################################
unbind -t vi-copy Enter
# setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# update default binding of 'Enter' to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
bind y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy '
bind C-y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy '
# reload keybind
bind C-r source-file ~/.tmux.conf
syntax on
set autoindent
set nowrap
set nobackup
set writebackup
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set incsearch
set hlsearch
set scrolloff=5
set modelines=1
" yank, deletes, etc. are copied to clipboard
set clipboard=unnamed
" menu on completion
set wildmenu
set foldmethod=marker
" line numbers
set number
set numberwidth=5
" horizontal cursor highlight
" set cursorline
" indent visual block
:vnoremap < <gv
:vnoremap > >gv
" 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 backspace=indent,eol,start whichwrap+=<,>,[,]
set laststatus=2
set statusline=%<%f%h%m%r%=\ %l,%c%V\ %P
" GUI options
set guifont=Source\ Code\ Pro\ Light:h11
" - 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 backup off
set nobackup
set nowb
set noswapfile
" LEADER key mapping
let mapleader = "\<Space>"
" 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>
" 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
"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 'MarcWeber/vim-addon-mw-utils' " dependency of garbas/vim-snipmat
NeoBundle 'altercation/vim-colors-solarized'
NeoBundle 'amix/vim-zenroom2'
NeoBundle 'bronson/vim-trailing-whitespace'
NeoBundle 'editorconfig/editorconfig-vim'
NeoBundle 'ervandew/supertab'
NeoBundle 'garbas/vim-snipmate'
NeoBundle 'junegunn/goyo.vim' " dependency of amix/vim-zenroom2
NeoBundle 'kchmck/vim-coffee-script'
NeoBundle 'kien/ctrlp.vim'
NeoBundle 'mileszs/ack.vim'
NeoBundle 'mustache/vim-mustache-handlebars'
NeoBundle 'othree/yajs.vim'
NeoBundle 'scrooloose/NERDCommenter'
NeoBundle 'scrooloose/nerdtree'
NeoBundle 'scrooloose/syntastic'
NeoBundle 'terryma/vim-multiple-cursors'
NeoBundle 'tomtom/tlib_vim' " dependency of garbas/vim-snipmate
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
" use theme from junegunn/seoul256.vim
if has('gui_running')
set background=light
colorscheme solarized
else
" set background=dark
" colorscheme strange
set background=light
" let g:solarized_termcolors=16
let g:solarized_visibility = "high"
let g:solarized_contrast = "high"
let g:solarized_termtrans=1
set t_Co=256 " force vim to use 256 colors
let g:solarized_termcolors=256 " use solarized 256 fallback
colorscheme solarized
endif
" 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
" CtrlP
nnoremap <Leader>r :CtrlPClearCache<cr>call s:UpdateNERDTree()<cr>
" recommended syntastic settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
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'
let g:syntastic_javascript_checkers = ['eslint']
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
" allow JSX in .js-files
let g:jsx_ext_required = 0
" 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

screenshot

vim-tmux.png

vim-tmux

colorscheme

Solarized (light) in both iterm2 and vim

vim

The .vimrc is not cleaned up or anything, there's a few ongoing experiments to improve my setup. There's a few neat features like <Leader>z to enter distraction-free mode.

tmux

A few convenience keybindings to resize panes. Shows windows in the lower left. The window title contains the current command that is running in that window, or the cwd. and shows the current git-branch and time in the lower right.

zsh

I use a stripped-down version of the lambda theme. I don't need git status or the cwd since that's shown in the tmux status bar.

iterm2

I use a custom-built borderless iterm2 (in which I adjusted the margins a little bit): https://github.com/jaredculp/iterm2-borderless-padding

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