From 6d88ca4fa1f6e76cfa315fe70e04bd63008c00e4 Mon Sep 17 00:00:00 2001 From: Shy Date: Tue, 28 Mar 2017 17:50:56 +0200 Subject: [PATCH] Replace current buffer if unchanged --- c4ctrl.vim | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/c4ctrl.vim b/c4ctrl.vim index fe30b11..0a0385a 100644 --- a/c4ctrl.vim +++ b/c4ctrl.vim @@ -47,7 +47,11 @@ function C4ctrl(cmd, ...) if stridx("get", a:cmd) == 0 " Read current status into new buffer - new + if getbufinfo("%")[0].changed + vnew + else + enew + endif set filetype=conf silent execute "0 read !" s:c4ctrl "-o -" @@ -67,7 +71,13 @@ function C4ctrl(cmd, ...) echoerr "Error: could not open file" s:fn return endif - execute "new" fnameescape(s:fn) + + if getbufinfo("%")[0].changed + vnew + else + enew + endif + execute "edit" fnameescape(s:fn) elseif stridx("set", a:cmd) == 0 " Set preset from current buffer