Last active
August 29, 2015 14:05
-
-
Save flipjs/f1f51d7d019c955fd87b to your computer and use it in GitHub Desktop.
VIM: Swap files between split windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! MarkWindowSwap() | |
let g:markedWinNum = winnr() | |
endfunction | |
function! DoWindowSwap() | |
"Mark destination | |
let curNum = winnr() | |
let curBuf = bufnr( "%" ) | |
exe g:markedWinNum . "wincmd w" | |
"Switch to source and shuffle dest->source | |
let markedBuf = bufnr( "%" ) | |
"Hide and open so that we aren't prompted and keep history | |
exe 'hide buf' curBuf | |
"Switch to dest and shuffle source->dest | |
exe curNum . "wincmd w" | |
"Hide and open so that we aren't prompted and keep history | |
exe 'hide buf' markedBuf | |
endfunction | |
nmap <silent> <leader>mw :call MarkWindowSwap()<CR> | |
nmap <silent> <leader>pw :call DoWindowSwap()<CR> | |
" - sgriffin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment