在iterm2中直接fzf命令进入文件检索视图时,按下回车时不自动进入vim。但是在vim中使用FZF全局命令选中时却可以。经过一番查找资料原来是和本身fzf设计有关
fzf is designed to be a 'Unix filter' meaning it reads from stdin and prints to stdout. If no stdin pipe is provided, it lists files from the current directory as a useful default.
解决办法:设置别名通过脚本提前进入vim环境否则回车的选中则会<u>"从标准输入读取并打印到标准输出"</u>
alias v='nvim $(fzf)'
参考github问答
- 官方文档: https://github.com/junegunn/fzf#usage
- 解决办法: https://github.com/junegunn/fzf/issues/542
- FZF操作文档: https://github.com/junegunn/fzf/blob/master/README-VIM.md
<u>根据自己所使用的终端中局在.bash_rc或者.zshrc中设置别名</u>
shell
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
# 注意使用单引号
alias whatnameyouwant='vim $(fzf)';
vim-airline
shell
# 安装vim plug包管理器
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# 在.vimrc中自动加载配置
call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
call plug#end()
# 关闭vim重新打开时执行安装命令
:PlugInstall
# 设置powerline主题
# 如果没有安装过字体
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh
cd ..
rm -rf fonts
# 在.vimrc中加入此配置
# 设置字体的配置需要在set语句后面,否则主题会加载失败
let g:airline_powerline_fonts = 1
# 例如一下配置
set t_Co=256
syntax on
set term=xterm
set rtp+=/usr/local/opt/fzf
let &t_AB="\e[48;5;%dm"
let &t_AF="\e[38;5;%dm"
let g:airline_powerline_fonts = 1
fzf安装及配置
shell
brew install fzf
# 安装常用的键绑定和模糊完成
$(brew --prefix)/opt/fzf/install
# .zhrc文件中配置FZF的展示效果
export FZF_DEFAULT_OPTS=‘—height=40% —preview=“cat {}” —preview-window=right:60%:wrap’
<u>最终效果</u>
