fzf to open vim makes my terminal wacky
Just trying to use fzf to open files to edit with vim....
fzf | xargs -0 -r vim
opens the file correctly, but once I exit vim my term is stuck in some kind of loop where I can't type anything. All I can do is press enter and it returns a new prompt on the same line... over and over again. What am I missing here?
About this post
- Posted
- Archived
- Score
- 1 · 100% up
- Kind
- Text
- ID
- ced6ck
4 comments
This is because vim's stdin (standard input) is not your keyboard like it should be, but whatever stdin xargs gives to it, which isn't the keyboard too since xargs's stdin is fzf's stdout.
The invalid state of the terminal can be fixed by running
tput reset, which resets all temporary settings a terminal might have - including show/hide the cursor, write/discard characters you type on the screen, etc.I think that doing
vim $(fzf)might be a better approach compared to yours - or any other approach that doesn't involve hijacking vim's stdin.Thank you! vim $(fzf) works well and I understand the issue with the other approach.
This also happens in the TTY...
Use fzf.vim which is a vim plugin and does what you want better with less surprises :)