Published: 02.05.2021 | Edited: 09.05.2021 | Tags: 100daystooffload

Smarter global search for vim and fzf

The first jab I have received yesterday removed most of my productivity today as I was shackled to the bed up until the very evening. Here are two more improvements for my vim fzf series described most recently in the previous post and some other posts mentioned there, tracking my overall progress on the issue. The current setup is quite useful but it can be improved even further.

Differentiate between global and local search

It is possible to force some fzf actions to operate on the global home scale and some on the current working directory in a sort of a hybrid approach. I have configured it in .zshrc like this:

export FZF_DEFAULT_COMMAND="fd --type f"
export FZF_CTRL_T_COMMAND="fd --type f . --full-path $HOME"

This way with all the previous setup in place, I can edit files in the current working directory running gf in the terminal or pressing this sequence in vim, while still access all folders and files in my home by pressing ALT+C and CTRL+T, which I find myself using less often, especially with the z jumping utility available.

GLobal / local search in vim as well

The above can also be ported to vim so there I can also easily access either files stemming from the current working directory or to access files in the home folder globally, inserting one additional line in .vimrc, inspired by a comment from the fzf author:

nmap <silent> gF :<C-u>Files ~<CR>

So there's already mentioned gf for the local files and now also a gF for accessing all files in home folder. Enjoy!

This is a 53th post of #100daystooffload.