summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-12-18 12:19:29 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-12-18 12:19:29 +0900
commitb5850ebd4c70cad83cabbe678bf7627758841a12 (patch)
tree3e0963878f209a93a9a4935b2341a4bedd6cc583
parentac0a62e494fb3647a166a57d25ad67750d75acf6 (diff)
[vim] Open selected file in the current window if it's empty
Close #451
-rw-r--r--plugin/fzf.vim8
1 files changed, 7 insertions, 1 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index d8106935..a391e331 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -409,10 +409,16 @@ function! s:cmd_callback(lines) abort
augroup END
endif
try
+ let empty = empty(expand('%')) && line('$') == 1 && empty(getline(1)) && !&modified
let autochdir = &autochdir
set noautochdir
for item in a:lines
- execute cmd s:escape(item)
+ if empty
+ execute 'e' s:escape(item)
+ let empty = 0
+ else
+ execute cmd s:escape(item)
+ endif
if exists('#BufEnter') && isdirectory(item)
doautocmd BufEnter
endif