Skip to content

Instantly share code, notes, and snippets.

@dahu
Created May 18, 2012 08:08
Show Gist options
  • Save dahu/2723903 to your computer and use it in GitHub Desktop.
Save dahu/2723903 to your computer and use it in GitHub Desktop.
Diffalicious - Compare two mouse-selected texts in Vim
" Diffalicious - Compare two mouse-selected texts in Vim
" Barry Arthur, 2012 5 18
let s:second_window_text = "Select text to compare with other window and press <enter> here."
function! Diffalicious()
tabnew
call DiffPasteIt()
botright vnew
call setline(1, s:second_window_text)
nnoremap <buffer> <cr> :call DiffPartTheSecond()<cr>
endfunction
function! DiffPasteIt()
put! *
$ delete _
set buftype=nofile
diffthis
endfunction
function! DiffPartTheSecond()
if getline(1) != s:second_window_text
echom "This doesn't look like a Diffalicious tab. Aborting cowardly."
return
endif
% delete _
call DiffPasteIt()
endfunction
nnoremap <leader>D :call Diffalicious()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment