[x] I have read through the manual page of fzf (man fzf)
[x] I have searched through the existing issues
What I want to do
I want to insert a path of my bookmark list in cmdline mode.
My bookmark list is like bellow. This is csv. First column is name and second is path.
$ cat ~/bookmarks
WIP,$HOME/Desktop/WIP
Projects,$HOME/Documents/projects
MEDIA,/Volumes/MEDIA
temp with space,$HOME/Downloads/temp with space
In case opening or saving a file, I want to run fzf to choose one of my bookmark path with <C-x>b.
For example, I type bellow
:e <C-x>b proj<Enter>
for completing bellow.
:e $HOME/Documents/projects
Problem
I wrote a function and a map in my vimscript.
Then I got a E565 error when typing :e <C-x>b.
Error messages are bellow.
Error detected while processing function <SNR>1_FzfBookmark[9]..fzf#run[80]..function <SNR>1_FzfBookmark[9]..fzf#run[63]..<SNR>9_execute_term[3]..<SNR>9_split:
line 31:
E565: Not allowed to change text or change window: botright 13new
Error detected while processing function <SNR>1_FzfBookmark:
line 9:
E171: Missing :endif
How can I resolve this?
Vim script for reproduction
For reproduction, start vim with command bellow.
$ vim -Nu reproduction.vim
reproduction.vim is
set nocompatible hidden laststatus=2
if !filereadable('/tmp/plug.vim')
silent !curl --insecure -fLo /tmp/plug.vim
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
endif
source /tmp/plug.vim
call plug#begin('/tmp/plugged')
Plug 'junegunn/fzf', { 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
call plug#end()
autocmd VimEnter * PlugClean! | PlugUpdate --sync
function! s:FzfBookmark()
let l:BS = "\u08" " <C-h>
let l:cmdtype = getcmdtype()
let l:args = {
\ 'source': 'cat $HOME/bookmarks',
\ 'sink': { lines -> lines },
\ 'down': '50%',
\ } " sink does nothing
if l:cmdtype == ':'
let l:list = fzf#run(fzf#wrap(l:args))
if len(list)
return escape(substitute(list[0], '^.\{-,},', '', ''), ' ')
else
return 'a' . l:BS " workaround for redraw problem
endif
else
let l:list = fzf#run(fzf#wrap(l:args))
endif
endfunction
cnoremap <expr> <C-x>b <SID>FzfBookmark()
man fzf
)What I want to do
I want to insert a path of my bookmark list in cmdline mode. My bookmark list is like bellow. This is csv. First column is name and second is path.
In case opening or saving a file, I want to run fzf to choose one of my bookmark path with
<C-x>b
. For example, I type bellowfor completing bellow.
Problem
I wrote a function and a map in my vimscript. Then I got a E565 error when typing
:e <C-x>b
. Error messages are bellow.How can I resolve this?
Vim script for reproduction
For reproduction, start vim with command bellow.
reproduction.vim
isEnvironments
vim
fzf
fzf.vim