diff --git a/Examples-(vim).md b/Examples-(vim).md index 2289088..b7801d5 100644 --- a/Examples-(vim).md +++ b/Examples-(vim).md @@ -306,4 +306,24 @@ The default value of `g:netrw_dirhistmax` is 10. You might be interested in incr ```viml let g:netrw_dirhistmax = 1000 +``` + +### Fuzzy file template search + +Say you have a folder with files in it you use for templating, and you want a fzf menu to choose which file will be loaded: + +```viml +" +" choose from templates and apply to file +" +function! s:read_template_into_buffer(template) + " has to be a function to avoid the extra space fzf#run insers otherwise + execute '0r ~/.vim/templates/'.a:template +endfunction + +command! -bang -nargs=* LoadTemplate call fzf#run({ + \ 'source': 'ls -1 ~/.config/nvim/templates', + \ 'down': 20, + \ 'sink': function('read_template_into_buffer') + \ }) ``` \ No newline at end of file