Fuzzy file search prompt ready upon vim entrance
Posted on
When I want to work on a project, I type vim .
, from my Terminal, in this
project's directory.
This brings up Netrw, the default file explorer in Vim.
In 90% of the time, I then fuzzy search the files I need to work on.
Do you see some inefficiency here?
What if I could be prompted with the fuzzy file search, as soon as I enter Vim?
Here is a little snippet I came up with and put in my .vimrc
file to enable
that.
function MyVimEnter()
if argc() == 1 && argv(0) == '.'
execute "Files"
endif
return
endfunction
" The 'nested' before call allows nested autocmds, important for
" syntax detection etc.
autocmd VimEnter * nested call MyVimEnter()
Now in the other 10% of the time, I can just hit Esc
key to dismiss the Fuzzy
file search.
In the fuzzy file search, in my case
FZF.vim, I can pick, using the Tab
key,
the few files I know will be working on and once ready hit Enter
, and boom I
have all the buffers I need to mess up with.
I hope this gives you some lead to improve your "project entrance" workflow.