• vim的Dirvish中文文档


    简介

    使用它,可避免微软文件管理器,因为它会崩溃!
    Dirvish是极简目录查看器.转储路径列表到Vim缓冲区中并提供一些快捷键.

    因为每个Dirvish缓冲区名都是字面目录路径,所以可:cd到目录,

    :cd %
    
    • 1

    创建新文件,

    :edit %/foo.txt
    
    • 1

    expand()目录路径,

    :let &titlestring=expand('%',1)
    
    • 1

    并使用如(unimpaired.vim)]f/[f的补全插件命令.
    可用普通的yank,:read,gfVim命令.它永远不会修改文件系统.

    如果编辑缓冲区,Dirvish会自动禁用隐藏,以便可看到全文.

    映射

    命令意思
    <Plug>(dirvish_up)-打开当前文件目录或第[count]个父目录

    局部,缓冲区本地(文件类型=dirvish)映射:

    映射意思
    G?,显示帮助.
    [count]R重新加载当前目录.(:edit也可以),如果给定,设置g:dirvish_mode[count].助记:更高[count]=>更多文件.
    <Plug>(dirvish_quit)gq退出并返回到原文件.
    <Plug>(dirvish_up)-打开第[count]个父目录.
    <Plug>(dirvish_split_up)新窗口中打开第[count]个父级.
    <Plug>(dirvish_vsplit_up)新垂直窗口中打开第[count]个父级.
    <2-LeftMouse>i<CR>打开光标处文件.
    {Visual}I{Visual}<CR>打开选定文件.
    o在新窗口中打开文件.
    {Visual}O新窗口中打开每个选定文件.
    a新垂直窗口中打开文件.
    {Visual}A新垂直窗口中打开每个选定文件.
    K显示文件信息.[count]显示目录大小.
    {Visual}K显示选定文件信息.[count]显示目录大小.
    p预览光标处的文件.
    CTRL-N预览下一个文件.
    CTRL-P预览前一个文件.
    <Plug>(dirvish_arg)x在本地arglist添加/删除文件.
    {Visual}x添加选定文件到本地arglist.
    dax启动新空本地arglist.
    .在命令行中插入:!{path}.
    {Visual}.在命令行中插入:Shdo {}.
    [count].在命令行中插入:Shdo!{}.
    ~打开家目录.
    cd设置本地当前目录.:lcd
    [count]cd设置全局当前目录.:cd

    命令

    命令意思
    :Dirvish打开当前目录,:Dirvish %也可以
    :Dirvish{path}打开位于{path}的目录,如果{path}是文件,则打开其父目录

    函数

    函数意思
    dirvish#open()同下
    [range]dirvish#open({cmd}, {bg})[range]区间中,执行{cmd} ("edit", "vsplit", "split", "tabedit")命令.{bg}为`0(当前窗口)
    dirvish#add_icon_fn(fn)注意路径图标
    dirvish#remove_icon_fn()注册图标

    选项

    g:dirvish_mode,控制如何列举与展示.
    1'suffixes'和'wildignore'决定排序和可见.
    2glob()序.
    :{cmd}为列举后执行命令.
    助记符:更高的数字=>更多文件,在第一次打开目录时,触发BufNew,未加载.加载后,触发FileType.可通过它覆盖映射,选项和内容.

    augroup dirvish_config
      autocmd!
    
      "映射`t`来在新tab中打开
      autocmd FileType dirvish
        \  nnoremap <silent><buffer> t :call dirvish#open('tabedit', 0)<CR>
        \ |xnoremap <silent><buffer> t :call dirvish#open('tabedit', 0)<CR>
    
      "映射`gr`来重载
      autocmd FileType dirvish nnoremap <silent><buffer>
        \ gr :<C-U>Dirvish %<CR>
    
      " 映射`gh`来隐藏点前缀文件.按`R`来切换
      autocmd FileType dirvish nnoremap <silent><buffer>
        \ gh :silent keeppatterns g@\v/\.[^\/]+/?$@d _<cr>:setl cole=3<cr>
    augroup END
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

    常见问题解答

    'splitbelow'和'splitright'控制拆分窗口位置.
    如何分组或排序目录?

    :sort ,^.*[\/],
    :sort ,^.*[^\/],
    //上面为顶部,下面为底部排序.
    let g:dirvish_mode = ':sort ,^.*[\/],'
    //来自动排序.
    
    • 1
    • 2
    • 3
    • 4
    • 5

    用了g:dirvish_relative_paths,则用

    let g:dirvish_mode = ':sort ,^\v(.*[\/])|\ze,'
    
    • 1

    如何过滤?

    :g/foo/d
    let g:dirvish_mode = ':silent keeppatterns g/foo/d _'
    //自动过滤
    :g@\v/\.[^\/]+/?$@d
    //删除显示隐藏文件.
    
    • 1
    • 2
    • 3
    • 4
    • 5

    自动化的话:

    let g:dirvish_mode = ':silent keeppatterns g@\v/\.[^\/]+/?$@d _'
    autocmd FileType dirvish silent keeppatterns g@\v/\.[^\/]+/?$@d _
    
    • 1
    • 2

    要显示,则用撤销,要再次隐藏,用重载.

    禁用映射

    augroup dirvish_config
      autocmd!
      autocmd FileType dirvish silent! unmap <buffer> <C-p>
    //禁用<C-p>
    augroup END
    
    • 1
    • 2
    • 3
    • 4
    • 5

    禁用所有本缓冲:

    :mapclear <buffer>
    
    • 1

    :noswapfile避免交换文件.
    :Shdo可批量删/重命名/其他动作文件.因为:'<,'>call delete(getline('.'))太长了.
    覆盖netrw:Explore,:Sexplore,:Vexplore命令?
    如下放入vimrc中:

    let g:loaded_netrwPlugin = 1
    command! -nargs=? -complete=dir Explore Dirvish <args>
    command! -nargs=? -complete=dir Sexplore belowright split | silent Dirvish <args>
    command! -nargs=? -complete=dir Vexplore leftabove vsplit | silent Dirvish <args>
    
    • 1
    • 2
    • 3
    • 4

    如何内联(如树样式视图)扩展目录?

    augroup dirvish_config
      autocmd!
      autocmd FileType dirvish
          \ nnoremap <silent><buffer> t ddO<Esc>:let @"=substitute(@", '\n', '', 'g')<CR>:r ! find "<C-R>"" -maxdepth 1 -print0 \| xargs -0 ls -Fd<CR>:silent! keeppatterns %s/\/\//\//g<CR>:silent! keeppatterns %s/[^a-zA-Z0-9\/]$//g<CR>:silent! keeppatterns g/^$/d<CR>:noh<CR>
    "有点麻烦.会使用"寄存器
    augroup END
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
  • 相关阅读:
    电脑c盘分区太小如何可以扩大,电脑c盘不够用了,如何给电脑分区
    力扣打卡之X的平方根
    阿里巴巴余军:钉钉宜搭低代码实践之路
    电商API知识问答
    【大厂高频真题100题】单词拆分Ⅱ 真题练习第8题 持续更新~
    Linux系统编程系列之进程间通信-IPC对象
    【算法基础】TOPSIS法
    【博客笔记+java+测试】
    Understanding JSON Schema
    Gorm源码学习-数据库连接
  • 原文地址:https://blog.csdn.net/fqbqrr/article/details/125451775