其实之前就已经用 F8 查看 svn diff 有四五年了,
但是一直懒得做成一个 diff mode 的,今天服务器搬迁没事干,就折腾了一下,效果还不错。
用法:
按 F8 进入 diff 模式,比较当前正在编辑的文件
或者
按 g 再按 F8 可以看到当前目录下运行 svn diff 命令的输出。
不论是以上哪种情况,再按 F8 回到之前的状态。
-------------------
" 查看 svn diff,flw 很得意的创意
function FlwSvnDiffToggle()
if bufexists( "__SVN_DIFF__" )
bwipeout __SVN_DIFF__
else
if exists("t:flwsvndiff")
diffoff!
let l:fileName = t:flwsvndiff
unlet t:flwsvndiff
exec "bwipeout " . l:fileName
else
let t:flwsvndiff = expand("%:h") . "/.svn/text-base/" . expand("%:t") . ".svn-base"
let l:ft = &ft
exec "silent vert diffsplit " . t:flwsvndiff
set readonly
set buftype=nofile
exec "set ft=" . l:ft
wincmd p
autocmd VimResized * :wincmd =
endif
endif
endfunction
" 绑定 F8 成为开启、关闭 svn diff 效果的快捷键
nmap :call FlwSvnDiffToggle()
nmap g :new __SVN_DIFF__ :read !svn diff:set syntax=diff buftype=nofilegg
阅读(6551) | 评论(3) | 转发(0) |