Vim: Delete Buffer When Quitting Split Window
Posted
by
Rafid K. Abdullah
on Stack Overflow
See other posts from Stack Overflow
or by Rafid K. Abdullah
Published on 2010-12-24T19:11:06Z
Indexed on
2010/12/24
20:54 UTC
Read the original article
Hit count: 319
I have this very useful function in my .vimrc:
function! MyGitDiff()
!git cat-file blob HEAD:% > temp/compare.tmp
diffthis
belowright vertical new
edit temp/compare.tmp
diffthis
endfunction
What it does is basically opening the file I am currently working on from repository in a vertical split window, then compare with it. This is very handy, as I can easily compare changes to the original file.
However, there is a problem. After finishing the compare, I remove the split window by typing :q. This however doesn't remove the buffer from the buffer list and I can still see the compare.tmp file in the buffer list. This is annoying because whenever I make new compare, I get this message:
Warning: File "temp/compare.tmp" has changed since editing started.
Is there anyway to delete the file from buffers as well as closing the vertical split window?
© Stack Overflow or respective owner