类似FZF的快速切换到目录的方法?是否在Vim FZF中包含隐藏文件?
我正在寻找一种方法来快速地将我的Vim目录更改为通过FZF类型的方法找到的目录。我知道它代表模糊文件搜索器,而不是模糊目录搜索器,但我相信有一个类似的工具或一个隐藏的功能可以使用,并受益于切换目录这么快 例如: 我想去的目录:~/Notes/Class 1/04-24-2020 我要键入的内容:类似FZF的快速切换到目录的方法?是否在Vim FZF中包含隐藏文件?,vim,fzf,vim-fzf,Vim,Fzf,Vim Fzf,我正在寻找一种方法来快速地将我的Vim目录更改为通过FZF类型的方法找到的目录。我知道它代表模糊文件搜索器,而不是模糊目录搜索器,但我相信有一个类似的工具或一个隐藏的功能可以使用,并受益于切换目录这么快 例如: 我想去的目录:~/Notes/Class 1/04-24-2020 我要键入的内容: :FZF class 1 04 24 提前谢谢 额外的问题:我如何将隐藏目录包含到这个目录中?如果我想编辑隐藏在.config中的init.vim配置文件,我将如何传递包含该文件的参数 编辑:下面列出
:FZF class 1 04 24
提前谢谢
额外的问题:我如何将隐藏目录包含到这个目录中?如果我想编辑隐藏在.config中的init.vim配置文件,我将如何传递包含该文件的参数
编辑:下面列出的奖金问题的答案。找到了“包括隐藏文件”的答案
在下面的示例中,我使用fdfind。你想用什么就用什么
command! -nargs=? -complete=dir AF
\ call fzf#run(fzf#wrap(fzf#vim#with_preview({
\ 'source': 'fdfind --type f --hidden --follow --exclude .git --no-ignore . '.expand(<q-args>)
\ })))
命令-纳格斯=-完成=直接AF
\使用预览调用fzf#run(fzf#wrap(fzf#vim#)({
\'source':'fdfind--type f--hidden--follow--exclude.git--no ignore'.expand()
\ })))
您可以使用上面的代码,但是如果您正在寻找一个更丰富的配置添加,那么您可以:
" Terminal buffer options for fzf
autocmd! FileType fzf
autocmd FileType fzf set noshowmode noruler nonu
" nnoremap <silent> <Leader><Leader> :Files<CR>
nnoremap <silent> <expr> <Leader><Leader> (expand('%') =~ 'NERD_tree' ? "\<c-w>\<c-w>" : '').":Files\<cr>"
nnoremap <silent> <Leader>C :Colors<CR>
nnoremap <silent> <Leader><Enter> :Buffers<CR>
nnoremap <silent> <Leader>L :Lines<CR>
nnoremap <silent> <Leader>ag :Ag <C-R><C-W><CR>
nnoremap <silent> <Leader>AG :Ag <C-R><C-A><CR>
xnoremap <silent> <Leader>ag y:Ag <C-R>"<CR>
nnoremap <silent> <Leader>` :Marks<CR>
" nnoremap <silent> q: :History:<CR>
" nnoremap <silent> q/ :History/<CR>
" inoremap <expr> <c-x><c-t> fzf#complete('tmuxwords.rb --all-but-current --scroll 500 --min 5')
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
inoremap <expr> <c-x><c-d> fzf#vim#complete#path('blsd')
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
function! s:plug_help_sink(line)
let dir = g:plugs[a:line].dir
for pat in ['doc/*.txt', 'README.md']
let match = get(split(globpath(dir, pat), "\n"), 0, '')
if len(match)
execute 'tabedit' match
return
endif
endfor
tabnew
execute 'Explore' dir
endfunction
command! PlugHelp call fzf#run(fzf#wrap({
\ 'source': sort(keys(g:plugs)),
\ 'sink': function('s:plug_help_sink')}))
function! RipgrepFzf(query, fullscreen)
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
let initial_command = printf(command_fmt, shellescape(a:query))
let reload_command = printf(command_fmt, '{q}')
let options = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
if a:fullscreen
let options = fzf#vim#with_preview(options)
endif
call fzf#vim#grep(initial_command, 1, options, a:fullscreen)
endfunction
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
fzf的终端缓冲区选项
autocmd!文件类型fzf
autocmd文件类型fzf set noshowmode noruler nonu
“nnoremap:文件
nnoremap(展开('%')=~'NERD\u tree'?“\\”:''。“:文件\”
nnoremap C:颜色
nnoremap:缓冲区
nnoremap L:线条
nnoremap ag:ag
nnoremap AG:AG
xnoremap ag y:ag“
nnoremap`:标记
“nnoremap q::历史:
“nnoremap q/:历史/
“inoremap fzf#complete('tmuxwords.rb--除当前外全部--滚动500--分钟5')
imap(fzf完整字)
imap(fzf完整路径)
inoremap fzf#vim#complete#路径('blsd'))
imap(fzf完整文件ag)
imap(fzf完整生产线)
功能!s:插头、帮助、水槽(线路)
设dir=g:plugs[a:line].dir
对于['doc/*.txt','README.md'中的pat
让match=get(拆分(globpath(dir,pat),“\n”),0,”)
如果len(匹配)
执行“tabedit”匹配
返回
恩迪夫
外循环
塔布纽
执行“Explore”dir
端功能
命令!PlugHelp调用fzf#run(fzf#wrap({
\“源”:排序(键(g:plugs)),
\“接收器”:函数('s:plug\u help\u sink'))
功能!RipgrepFzf(查询,全屏)
让命令_fmt='rg--列--行号--无标题--颜色=始终--智能大小写%s | | true'
让initial_command=printf(command_fmt,shellescape(a:query))
让reload_command=printf(command_fmt,{q})
让选项={'options':['-phony','-query',a:query'-bind',change:reload:'.reload_命令]}
如果a:全屏
让选项=fzf#vim#带预览(选项)
恩迪夫
调用fzf#vim#grep(初始#命令,1,选项,a:全屏)
端功能
命令-nargs=*-bang RG call RipgrepFzf(,0)
我保存在.bashrc中的I,您可以使用它来选择
任何文件通过fzf,并将其传递给任何您想要的程序。信息技术
可与vlc、evince等GUI程序以及命令行工具一起使用
像cd、猫、尾巴、头等等。此外,您还可以循环通过您的
历史记录并在fzf执行操作后展开命令时查找该命令
在您的情况下,只需输入终端:
f cd
fzf将启动,在您选择目录后,您将立即在那里cd
我把函数放在下面,我得到了灵感
#使用fzf运行命令/应用程序并选择路径/文件。
#始终将终端控制权返还给用户(例如,在打开GUI时)。
#所使用的完整命令将与其他命令一样出现在历史记录中
#其他(注意:为了实现这一点,我将shell的活动历史记录写入
#~/.bash_历史)
#
#用法:
#f cd(按回车键,选择路径)
#f cat(点击回车键,选择文件)
#f vim(点击回车键,选择文件)
#f vlc(点击回车键,选择文件)
f(){
#如果没有传递参数,只需启动fzf
如果[$#-eq 0]
然后
fzf
返回0
fi
#存储程序
program=“$1”
#从列表中删除第一个参数
转移
#存储任何选项标志
选项=“$@”
#存储来自fzf的参数
参数=$(fzf--多)
#如果未传递任何参数(例如,如果按下Esc键),则返回终端
如果[-z“${arguments}”];则
返回1
fi
#通过在每个参数周围加上单引号来清理命令
#首先,在中任何预先存在的单引号旁边添加一个额外的单引号
#原始的论点,把它们放在一行。
对于“${arguments[@]}”中的arg,请执行以下操作
参数=$(回显“$arg”| sed“s/'/'/g;s/*/'&'/g;s/\n//g”)
完成
#如果程序在GUI列表中,请添加“&”
如果[[“$program”=~ ^(鹦鹉螺|扎图拉|埃文斯| vlc | eog |科洛尔油漆)$];那么
arguments=“$arguments&”
fi
#将shell的活动历史记录写入~/.bash_history。
历史-w
#将带有经过清理的参数的命令添加到.bash_历史记录中
echo$program$options$arguments>>~/.bash\u历史记录
#将~/.bash_历史重新加载到shell的活动历史中
历史-r
#执行历史记录中的最后一个命令
fc-s-1
}