如何为coc-explorer配置快捷键映射实现隐藏文件切换与窗口跳转
coc-explorer 配置操作指南
1. 检查隐藏文件可见状态
- 打开coc-explorer面板后,直接观察面板内是否展示
.开头的Unix类隐藏文件/系统隐藏文件,即可直观判断当前可见状态 - 也可在vim命令行执行
:echo CocRequest('explorer', 'getConfig', 'hidden'),返回值为true代表隐藏文件不可见,返回false代表隐藏文件可见
2. F5/F6 隐藏文件切换快捷键配置(不修改coc-settings.json)
直接将以下代码添加到你的init.vim(Neovim)或.vimrc(Vim)配置文件中即可生效,所有配置仅保存在vim主配置内,不会写入coc-settings.json,完全独立:
" F5:设置coc-explorer不显示隐藏文件 nnoremap <silent> <F5> :CocCommand explorer.setConfig hidden true<CR> " F6:设置coc-explorer显示隐藏文件 nnoremap <silent> <F6> :CocCommand explorer.setConfig hidden false<CR>
3. F7/F8 跳转coc-explorer面板快捷键配置
同样添加到vim主配置文件中即可,当打开多个coc-explorer面板时,可从编辑页直接跳转对应面板:
" F7:跳转至第一个打开的coc-explorer面板 nnoremap <silent> <F7> :for w in range(1, winnr('$')) | if getbufvar(winbufnr(w), '&filetype') == 'coc-explorer' | exe w . 'wincmd w' | break | endif | endfor<CR> " F8:跳转至第二个打开的coc-explorer面板 nnoremap <silent> <F8> :let cnt = 0 | for w in range(1, winnr('$')) | if getbufvar(winbufnr(w), '&filetype') == 'coc-explorer' | let cnt += 1 | if cnt == 2 | exe w . 'wincmd w' | break | endif | endif | endfor<CR>
内容的提问来源于stack exchange,提问作者icepl
相关产品推荐
相关产品推荐

