public
Created

current vim/tmux setup

  • Download Gist
.tmux.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
# Mac pastebin
set-option -g default-command "reattach-to-user-namespace -l zsh"
 
# Basics
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
unbind C-b
set -g prefix C-a
set -g base-index 1
set -s escape-time 0
 
# Remove default binding since we’re replacing
bind / split-window -h
bind - split-window -v
unbind %
 
# Pane navigation
#set-window-option -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind C-a last-window
 
# For beginning of line (Ctrl-A)
bind a send-prefix
 
# Status color
# to get a list run
#
# for i in {-1..255} ; do
# printf "\x1b[38;5;${i}mcolour${i}\n"
# done
 
set -g status-bg colour232
set -g status-fg white
 
# pane movement
bind g command-prompt -p "join pane from:" "join-pane -s '%%'"
bind s command-prompt -p "send pane to:" "join-pane -t '%%'"
 
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
 
# no qs and xs for borders
set-option -ga terminal-overrides ',*:enacs@:smacs@:rmacs@:acsc@'
 
set -g default-terminal "screen-256color"
# vim
setw -g mode-keys vi
# tmux 1.8 - press y in copy mode to copy selection to clipboard
bind -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
#bind [ copy-mode
#bind -t vi-copy v begin-selection
#bind -t vi-copy y copy-selection
#bind -t vi-copy V rectangle-toggle
#bind ] paste-buffer
 
# buffer
bind Space choose-buffer
 
# Mouse Crap
# http://tangledhelix.com/blog/2012/07/16/tmux-and-mouse-mode/
 
# Mouse scrolling
set -g mode-mouse on
 
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on
 
unbind +
bind + \
new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \;\
swap-pane -s tmux-zoom.0 \;\
select-window -t tmux-zoom
 
unbind _
bind _ \
last-window \;\
swap-pane -s tmux-zoom.0 \;\
kill-window -t tmux-zoom
.vimrc
VimL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pathogen
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use pathogen (http://www.vim.org/scripts/script.php?script_id=2332) for
" easier bundle management
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Theme/Colors
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set term=screen-256color
set t_Co=256
 
set background=light
" set background=dark
let g:solarized_termcolors=16
so ~/.vim/bundle/vim-colors-solarized/autoload/togglebg.vim
 
syntax on
" colorscheme maroloccio3
" colorscheme zenburn
colorscheme solarized
set guifont=Mensch:h13
set antialias
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Splits
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" split and be active in split instead of original
set splitbelow
set splitright
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set textwidth=0
set wrapmargin=0
set complete=.,b,u,]
map ,z :colorscheme grb256<cr>:set background=dark<cr>
" let g:netrw_liststyle=3 " Use tree-mode as default view
" let g:netrw_browse_split=4 " Open file in previous buffer
" let g:netrw_preview=1 " preview window shown in a vertically split
" Use Vim settings, rather then Vi settings (much better!).
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L
" This must be first, because it changes other options as a side effect.
set nocompatible
 
" Editable crontab
au BufEnter /private/tmp/crontab.* setl backupcopy=yes
 
" Set irregular syntax highlighting
au BufRead,BufNewFile *.hamlc setfiletype haml
 
" delimitmate no delay on <C-[> https://github.com/Raimondi/delimitMate/issues/87
let delimitMate_no_esc_mapping = 1
 
" save read only
cmap w!! %!sudo tee > /dev/null %
 
" better up down on wrapped
nnoremap j gj
nnoremap k gk
 
" open .vimrc
nmap gr :sp ~/.vimrc<cr>
 
" insert a single character
nmap gt i_<Esc>r
nmap gb a_<Esc>r
 
" Pressing return clears highlighted search
nnoremap <CR> :nohlsearch<CR>/<BS>
 
" Make , the personal leader key
let mapleader = ","
let maplocalleader = ","
 
" switch between files faster
map ,, <C-^>
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
 
" imap jj <C-[>
 
" command t make escape work
let g:CommandTCancelMap=['<ESC>']
" start in views or models
" map <Leader>v :CommandT app/views/<cr>
" map <Leader>m :CommandT app/models/<cr>
" map <Leader>t :CtrlP<CR>
" "map <leader>t :CommandTFlush<cr>:CommandT<cr>
let g:ctrlp_clear_cache_on_exit = 1
map <C-l> :CtrlPClearCache<CR>
 
" Make ' more useful, swap it with `
nnoremap ' `
nnoremap ` '
 
set backup " keep a backup file
set hidden " Allow Vim to manage hidden buffers effectively
set history=500 " keep 500 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" set number " show line numbers
 
runtime macros/matchit.vim " Enable extended % matching
 
filetype on " detect the type of file
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
 
set cf " enable error files and error jumping
set ffs=unix,dos,mac " support all three, in this order
set viminfo+=! " make sure it can save viminfo
set isk+=_,$,@,%,#,- " none of these should be word dividers, so make them not be
set title " show title in xterm
 
" Make completion useful
set wildmenu
 
" Ignore these files when completing names and in Explorer
set wildignore=.svn,CVS,.git,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,bundle,.sass-cache
 
" Specify which keys can move the cursor left/right to move to the
" previous/next line when the cursor is on the first/last character in that
" line
" set whichwrap+=<,>,[,]
 
" make /-style searches case-sensitive only if there is a capital letter in the search expression
set ignorecase
set smartcase
 
" vim togglecomment plugin
map ,/ :call CommentLineToEnd('#')<CR>+
map ,* :call CommentLinePincer('/* ', ' */')<CR>+
 
" automatically insert a \v before any search string, so search uses
" normal regexes
nnoremap / /\v
vnoremap / /\v
 
set gdefault " always apply substitutions globally on a line
 
" Clear out any search by typing <leader><space>
nnoremap <leader><space> :noh<cr>
 
" Sane searching
set hlsearch " Hilight search term
set showmatch " Show matching brackets
set incsearch " ... dynamically as they are typed
" turn of hlsearch temporarily
nmap <silent> <leader>n :silent :nohlsearch<CR>
 
" This line will make Vim set out tab characters, trailing whitespace and
" invisible spaces visually, and additionally use the # sign at the end of
" lines to mark lines that extend off-screen. For more info, see :h listchars.
set list
" set listchars=tab:▶\,trail:◀,extends:»,precedes:«
set listchars=tab:▸\ ,eol,trail:.,extends:#,nbsp:.
 
nmap \o :set paste!<CR>:set paste?<CR>
 
" Make trailing whitespace visible with ,s
nmap <silent> <leader>s :set nolist!<CR>
set nolist!
 
set scrolloff=3 " Start scrolling 3 lines before the border
 
set autoread " Automatically reread files that have been changed externally
 
" set relativenumber " show how far away each line is from the current one
" set undofile " save undo information
 
" Show buffer list and choose one
" nnoremap <C-e> :buffers<CR>:b<Space>
 
" Make ^e and ^y scroll 3 lines instead of 1
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
 
" shorten command-line text and other info tokens (see :help shortmess)
set shortmess=atI
 
" Only use one space after ., ? or ! with a join command
set nojoinspaces
 
" Use Q for formatting the current paragraph (or selection)
vmap Q gq
nmap Q gqap
 
" Make the tab key match bracket pairs
nnoremap <tab> %
vnoremap <tab> %
 
" Make ';' an alias for ':'
nnoremap ; :
" this is breaking the ctrl-p and nerdtree for some reason
" nnoremap : ;
 
" Useful trick when I've forgotten to `sudo' before editing a file:
cmap w!! w !sudo tee % >/dev/null
 
" Automagically save files when focus is lost
au FocusLost * silent! :wa
 
" ,W strips all trailing whitespace from current file
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
 
" Tab mappings.
map <leader>tt :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>to :tabonly<cr>
map <leader>tn :tabnext<cr>
map <leader>tp :tabprevious<cr>
map <leader>tf :tabfirst<cr>
map <leader>tl :tablast<cr>
map <leader>tm :tabmove
 
" Opens an edit command with the path of the currently edited file filled in
" Normal mode: <Leader>e
map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
 
" Opens a tab edit command with the path of the currently edited file filled in
" Normal mode: <Leader>t
"map <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
 
" Shift-tab to insert a hard tab
imap <silent> <S-tab> <C-v><tab>
 
" allow deleting selection without updating the clipboard (yank buffer)
vnoremap x "_x
vnoremap X "_X
 
" don't move the cursor after pasting
" (by jumping to back start of previously changed text)
noremap p p`[
noremap P P`[
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Files/Backups
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set backup " make backup file
" where to put backup file
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" directory is the directory for temp file
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set makeef=error.err " When using make, where should it dump the file
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Text Formatting/Layout
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set fo=tcrqn " See Help (complex)
set autoindent " autoindent
set nosmartindent " smartindent
set cindent " do c-style indenting
"set tabstop=2 " tab spacing (settings below are just to unify it)
set softtabstop=2 " unify
set shiftwidth=2 " unify
set expandtab " use spaces instead of tabs
"set nowrap " do not wrap lines
set smarttab " use tabs at the start of a line, spaces elsewhere
 
" Highlight trailing whitespace
highlight WhitespaceEOL ctermbg=DarkYellow guibg=DarkYellow
match WhitespaceEOL /\s\+$/
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Folding
" Enable folding, but by default make it act like folding is off, because folding is
" annoying in anything but a few rare cases
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nofoldenable " Turn on folding
set foldmethod=indent " Make folding indent sensitive
set foldnestmax=10
"set foldmethod=marker "
set foldlevel=1 " Don't autofold anything (but I can still fold manually)
"set foldopen-=search " don't open folds when you search into them
"set foldopen-=undo " don't open folds when you undo stuff
" nnoremap <Space> za
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" File Encoding
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set encoding="utf8" " We always want utf-8
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Windows
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
" Instead of having to press 'ctrl-w h' to move to the window to the left, just press ctrl-h,
" etc.
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" map <C-f> <C-w>_<C-w><Pipe>
 
nnoremap <C-W>O :call MaximizeToggle ()<CR>
nnoremap <C-W>o :call MaximizeToggle ()<CR>
nnoremap <C-W><C-O> :call MaximizeToggle ()<CR>
 
function! MaximizeToggle()
if exists("s:maximize_session")
exec "source " . s:maximize_session
call delete(s:maximize_session)
unlet s:maximize_session
let &hidden=s:maximize_hidden_save
unlet s:maximize_hidden_save
else
let s:maximize_hidden_save = &hidden
let s:maximize_session = tempname()
set hidden
exec "mksession! " . s:maximize_session
only
endif
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
" Enable OmniCompletion for Ruby
autocmd FileType ruby set omnifunc=rubycomplete#Complete
" ... and Rails
autocmd FileType ruby let g:rubycomplete_rails = 1
" ... and to include Classes in global completions
autocmd FileType ruby let g:rubycomplete_classes_in_global = 1
" Thorfile, Rakefile and Gemfile are Ruby
au BufRead,BufNewFile {Gemfile,Rakefile,Thorfile,config.ru,Capfile,*.rake} set ft=ruby
 
" Syntax highlight shell scripts as per POSIX,
" not the original Bourne shell which very few use
let g:is_posix = 1
 
" bind control-l to hashrocket
imap <C-l> <Space>=><Space>
 
" NERD_Tree support
let NERDTreeIgnore=['\.rbc$', '\~$']
map <Leader>d :NERDTreeToggle<CR>
map <leader>c :NERDTreeFind<cr>
 
" CTags
" map <Leader>rt :!ctags --extra=+f -R *<CR><CR>
let NERDTreeShowHidden=1
map <C-n> o<C-[>
 
au BufNewFile,BufRead *.term,Rakefile,Gemfile,Procfile,Vagrantfile,*.rake,*.ru setlocal ft=ruby
 
" View schema or routes file
" nmap <leader>vs :e db/schema.rb<cr>
" nmap <leader>vr :e config/routes.rb<cr>
"nmap <cr> :nohl<cr>
 
" source: http://vim.wikia.com/wiki/VimTip102
" Let <Tab> do all the autocompletion
" function! Smart_TabComplete()
" let line = getline('.') " curline
" let substr = strpart(line, -1, col('.')) " from start to cursor
" let substr = matchstr(substr, "[^ \t]*$") " word till cursor
" if (strlen(substr)==0) " nothing to match on empty string
" return "\<tab>"
" endif
" let has_period = match(substr, '\.') != -1 " position of period, if any
" let has_slash = match(substr, '\/') != -1 " position of slash, if any
" if (!has_period && !has_slash)
" return "\<C-X>\<C-P>" " existing text matching
" elseif ( has_slash )
" return "\<C-X>\<C-F>" " file matching
" else
" return "\<C-X>\<C-O>" " plugin matching
" endif
" endfunction
" inoremap <tab> <c-r>=Smart_TabComplete()<CR>
let vimclojure#HighlightBuiltins=1
let vimclojure#ParenRainbow=1
let g:slime_target = "tmux"
 
" Match parens, square and curly brackets
" but only if cursor is at end of line
 
" function! ConditionalPairMap(open, close)
" let line = getline('.')
" let col = col('.')
" if col < col('$') || stridx(line, a:close, col + 1) != -1
" return a:open
" else
" return a:open . a:close . repeat("\<left>", len(a:close))
" endif
" endf
" inoremap <expr> ( ConditionalPairMap('(', ')')
" inoremap <expr> { ConditionalPairMap('{', '}')
" inoremap <expr> [ ConditionalPairMap('[', ']')
 
let g:ctrlp_custom_ignore = '\.git$\|vendor\/bundle$\|vendor/vagrant$\|\.svn$'
 
let g:user_zen_expandabbr_key = '<c-b><c-b>'
let g:use_zen_complete_tag = 1
 
function! NS_camelcase(s)
"upcase the first letter
let toReturn = substitute(a:s, '^\(.\)', '\=toupper(submatch(1))', '')
"turn all '_x' into 'X'
return substitute(toReturn, '_\(.\)', '\=toupper(submatch(1))', 'g')
endfunction
 
function! NS_underscore(s)
"down the first letter
let toReturn = substitute(a:s, '^\(.\)', '\=tolower(submatch(1))', '')
"turn all 'X' into '_x'
return substitute(toReturn, '\([A-Z]\)', '\=tolower("_".submatch(1))', 'g')
endfunction
 
function! Snippet_RubyClassNameFromFilename()
let name = expand("%:t:r")
return NS_camelcase(name)
endfunction
 
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
 
if has("mac") || has("macunix")
nmap <D-j> <M-j>
nmap <D-k> <M-k>
vmap <D-j> <M-j>
vmap <D-k> <M-k>
endif
 
" MRU
nmap <leader>x :MRU<CR>
 
" Cmd-a
if has("mac") || has("macunix")
nmap <D-a> ggVG
endif
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vimux
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Run the current file with rspec
map <Leader>rr :call VimuxRunCommand("clear; spring rspec " . bufname("%"))<CR>
" Run command without sending sending a return
map <Leader>rn :call VimuxRunCommand("clear; bundle exec rspec " . bufname("%"))<CR>
" Run command without sending sending a return
map <Leader>rq :call VimuxRunCommand("clear; spring rspec " . bufname("%"), 0)<CR>
" Run the current file with spinach
map <Leader>rs :call VimuxRunCommand("clear; spring spinach " . bufname("%"))<CR>
" Prompt for a command to run map"
map <Leader>vp :VimuxPromptCommand<CR>
" Run last command executed by VimuxRunCommand
map <Leader>vl :VimuxRunLastCommand<CR>"
" Inspect runner pane map
map <Leader>vi :VimuxInspectRunner<CR>"
" Close vim tmux runner opened by VimuxRunCommand
map <Leader>vq :VimuxCloseRunner<CR>"
" Close all other tmux panes in current window
map <Leader>vx :VimuxClosePanes<CR>"
" Interrupt any command running in the runner pane map
map <Leader>vs :VimuxInterruptRunner<CR>"
 
 
" Quickly display a markdown preview of the current buffer
map <leader>m :%w ! markdown_doctor \| bcat<CR><CR>
 
" Tabularize
if exists(":Tabularize")
map <Leader>a= :Tabularize /=<CR>
map <Leader>a: :Tabularize /:\zs<CR>
endif

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.