Hi and thanks a lot for your software!
I would like to modify the behavior of fzf's Ctrl + t:
Instead of writing the file the user chose to stdout, Vim should open the file.
As suggested here I've tried to add a key binding:
export FZF_CTRL_T_OPTS="--bind 'enter:execute(vim {1} < /dev/tty);"
But this didn't work, Vim doesn't open the file.
Is there a way to configure what happens after the user has chosen a file using Ctrl + t?
Thanks!
The most basic thing you can do is
vim_fzf() {
vim "$(fzf)"
}
bind -x '"\C-t": vim_fzf'
There's more stuff in the wiki (for example the fe() function)
Thanks @xalexalex!
Based on your answer, I came up with this function that takes care of the case when the user hasn't selected a file:
# Search a file with fzf inside a Tmux pane and then open it in an editor
fzf_then_open_in_editor() {
local file=$(fzf-tmux)
# Open the file if it exists
if [ -n "$file" ]; then
# Use the default editor if it's defined, otherwise Vim
${EDITOR:-vim} "$file"
fi
}
bind -x '"\C-t": fzf_then_open_in_editor'
Most helpful comment
Thanks @xalexalex!
Based on your answer, I came up with this function that takes care of the case when the user hasn't selected a file: