Open arashm opened 3 years ago
I also wanted this behaviour and was able to cobble this together:
if !exists("b:fern_is_preview")
let b:fern_is_preview = 0
endif
function! FernPreviewToggle()
if b:fern_is_preview
:execute "normal \<Plug>(fern-action-preview:close)"
:execute "normal \<Plug>(fern-action-preview:auto:disable)"
nunmap <buffer> <C-d>
nunmap <buffer> <C-u>
let b:fern_is_preview = 0
else
:execute "normal \<Plug>(fern-action-preview:open)"
:execute "normal \<Plug>(fern-action-preview:auto:enable)<Plug>(fern-action-preview:open)"
nmap <silent> <buffer> <C-d> <Plug>(fern-action-preview:scroll:down:half)
nmap <silent> <buffer> <C-u> <Plug>(fern-action-preview:scroll:up:half)
let b:fern_is_preview = 1
endif
endfunction
nmap <silent> <buffer> p :call FernPreviewToggle()<CR>
It should be placed within the init_fern()
function as outlined here, so that it acts upon the buffer that fern is in.
It will only work so long as the preview is open/closed via the function.
Thanks for the great set of Plugins. I have this piece of config as suggested in the readme:
I use
<C-d>
and<C-u>
in the fern itself to jump up and down the list of directories/files as well, but setting it here causes the fern/vim to throw an error:Is there a way to only map those keys when a preview window is open, and do the regular
<C-d>
,<C-u>
when there's no preview window?