Author: Kyle Fuller <kyle@fuller.li> 2015-10-10 01:11:05 -0700 -0700
Committer: Kyle Fuller <kyle@fuller.li> 2015-10-10 01:11:05 -0700 -0700
Commit: affd28e0bc027f18e882e414f1a256b5ffc4a69d
Parent: 878a5fa7fdd404643b995e5a46976a3cdbd85142
[vim] Add pasteboard sync
diff --git a/.vimrc b/.vimrc
index 7eaf5011dbebf504df9bc216359b05ed5f149f34..466172cbe0ee136de58563b8d382642410f22148 100644
--- a/.vimrc
+++ b/.vimrc
@@ -12,6 +12,7 @@ Plug 'kylef/apiblueprint.vim'
Plug 'nanotech/jellybeans.vim'
Plug 'nvie/vim-flake8'
Plug 'scrooloose/syntastic'
+Plug 'sjl/vitality.vim'
Plug 'tpope/vim-sensible'
call plug#end()
@@ -71,6 +72,22 @@ autocmd FileType cpp set noexpandtab
autocmd FileType gitcommit setlocal spell textwidth=72
autocmd FileType markdown setlocal spell textwidth=79
autocmd FileType apiblueprint setlocal spell textwidth=79
+
+" Copy copy register to OS X general pasteboard
+function! PBCopy()
+ call system("pbcopy", getreg(""))
+endfunction
+
+" Paste from OS X general pasteboard to copy register
+function! PBPaste()
+ call setreg("", system("pbpaste"))
+endfunction
+
+" By the power of https://github.com/sjl/vitality.vim, copies and pastes
+" to the OS X pasteboard when switching between vim and other windows
+" (even in tmux)
+autocmd FocusLost * :call PBCopy()
+autocmd FocusGained * :call PBPaste()
" Yeah... these get typoed
command W w