CARVIEW |
Select Language
HTTP/2 200
date: Thu, 24 Jul 2025 02:39:25 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-robots-tag: none
etag: W/"9aa90d920ec6cde80932e071d1b3399c"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=Sug%2B4yKUDdMkY1Na%2B%2FgMRoThqW%2FxJykRzt4yft8uwUEoZtSGmnCgCm67io88tO%2B5zIvvW6d9JqhoSEIlOWNVYoEzb3XiNkXhCnsOFvKjwY1qzXXvqNIRq0wqpylMRxqADnXhtQNHsHy2vvgIRpNx2dymwqMzluC3kziPl3Bv7voUmcIJXnsbVoCRvVfOwMzMhKQG5dVnyj0O4g6qVM4Fm1aLSqhwkr1yxuftJYDr2j4oGJW6A1o2ZcxpkGqKmBvpUpBK80%2FRwKvk9EzPLybJQg%3D%3D--MKX3V5GHbZUcv%2F%2Bi--PXyL4G8MJhhkE3KAnzcBCg%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.468374630.1753324764; Path=/; Domain=github.com; Expires=Fri, 24 Jul 2026 02:39:24 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Fri, 24 Jul 2026 02:39:24 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 9F0E:35EBF4:12200FE:15FF8E4:68819CDC
Tips · lambdalisue/vim-fern Wiki · GitHub
Open bookmark:/// and return via
Skip to content
Navigation Menu
{{ message }}
-
-
Notifications
You must be signed in to change notification settings - Fork 49
Tips
Snuggs edited this page May 25, 2025
·
40 revisions
How to map a command to open a buffer parent directory or current working directory when the buffer is not a file
Use <C-r>=...<CR>
to specify a special function like below:
nnoremap <silent> <Leader>ee :<C-u>Fern <C-r>=<SID>smart_path()<CR><CR>
" Return a parent directory of the current buffer when the buffer is a file.
" Otherwise it returns a current working directory.
function! s:smart_path() abort
if !empty(&buftype) || bufname('%') =~# '^[^:]\+://'
return fnamemodify('.', ':p')
endif
return fnamemodify(expand('%'), ':p:h')
endfunction
Use FileType
autocmd to initialize fern buffer like:
function! s:init_fern() abort
echo "This function is called ON a fern buffer WHEN initialized"
" Open node with 'o'
nmap <buffer> o <Plug>(fern-action-open)
" Add any code to customize fern buffer
endfunction
augroup fern-custom
autocmd! *
autocmd FileType fern call s:init_fern()
augroup END
Use s:init_fern()
above like:
function! s:init_fern() abort
" Define NERDTree like mappings
nmap <buffer> o <Plug>(fern-action-open:edit)
nmap <buffer> go <Plug>(fern-action-open:edit)<C-w>p
nmap <buffer> t <Plug>(fern-action-open:tabedit)
nmap <buffer> T <Plug>(fern-action-open:tabedit)gT
nmap <buffer> i <Plug>(fern-action-open:split)
nmap <buffer> gi <Plug>(fern-action-open:split)<C-w>p
nmap <buffer> s <Plug>(fern-action-open:vsplit)
nmap <buffer> gs <Plug>(fern-action-open:vsplit)<C-w>p
nmap <buffer> ma <Plug>(fern-action-new-path)
nmap <buffer> P gg
nmap <buffer> C <Plug>(fern-action-enter)
nmap <buffer> u <Plug>(fern-action-leave)
nmap <buffer> r <Plug>(fern-action-reload)
nmap <buffer> R gg<Plug>(fern-action-reload)<C-o>
nmap <buffer> cd <Plug>(fern-action-cd)
nmap <buffer> CD gg<Plug>(fern-action-cd)<C-o>
nmap <buffer> I <Plug>(fern-action-hidden-toggle)
nmap <buffer> q :<C-u>quit<CR>
endfunction
https://github.com/preservim/nerdtree/blob/master/doc/NERDTree.txt#L247-L293
Note that some features are missing.
Use fern#smart#leaf
like below:
function! s:init_fern() abort
nmap <buffer><expr>
\ <Plug>(fern-my-expand-or-collapse)
\ fern#smart#leaf(
\ "\<Plug>(fern-action-collapse)",
\ "\<Plug>(fern-action-expand)",
\ "\<Plug>(fern-action-collapse)",
\ )
nmap <buffer><nowait> l <Plug>(fern-my-expand-or-collapse)
endfunction
Use fern#smart#drawer
like below:
function! s:init_fern() abort
nmap <buffer><expr>
\ <Plug>(fern-my-expand-or-enter)
\ fern#smart#drawer(
\ "\<Plug>(fern-open-or-expand)",
\ "\<Plug>(fern-open-or-enter)",
\ )
nmap <buffer><expr>
\ <Plug>(fern-my-collapse-or-leave)
\ fern#smart#drawer(
\ "\<Plug>(fern-action-collapse)",
\ "\<Plug>(fern-action-leave)",
\ )
nmap <buffer><nowait> l <Plug>(fern-my-expand-or-enter)
nmap <buffer><nowait> h <Plug>(fern-my-collapse-or-leave)
endfunction
Use <Plug>(fern-wait)
to wait enter
or leave
action like:
nmap <buffer> <Plug>(fern-my-enter-and-tcd)
\ <Plug>(fern-action-enter)
\ <Plug>(fern-wait)
\ <Plug>(fern-action-tcd:root)
nmap <buffer> <Plug>(fern-my-leave-and-tcd)
\ <Plug>(fern-action-leave)
\ <Plug>(fern-wait)
\ <Plug>(fern-action-tcd:root)
Use feedkeys()
to execute the <Plug>(fern-action-tcd:root)
like:
augroup my_fern_tcd
autocmd! * <buffer>
autocmd BufEnter <buffer> call feedkeys("\<Plug>(fern-action-tcd:root)")
augroup END
See https://github.com/lambdalisue/fern-mapping-project-top.vim
function! s:fern_init() abort
" Find and enter project root
nnoremap <buffer><silent>
\ <Plug>(fern-my-enter-project-root)
\ :<C-u>call fern#helper#call(funcref('<SID>map_enter_project_root'))<CR>
nmap <buffer><expr><silent>
\ ^
\ fern#smart#scheme(
\ "^",
\ {
\ 'file': "\<Plug>(fern-my-enter-project-root)",
\ }
\ )
endfunction
function! s:map_enter_project_root(helper) abort
" NOTE: require 'file' scheme
let root = a:helper.get_root_node()
let path = root._path
let path = finddir('.git/..', path . ';')
execute printf('Fern %s', fnameescape(path))
endfunction
Open bookmark:/// and return via <C-^>
function! s:fern_init() abort
" Open bookmark:///
nnoremap <buffer><silent>
\ <Plug>(fern-my-enter-bookmark)
\ :<C-u>Fern bookmark:///<CR>
nmap <buffer><expr><silent>
\ <C-^>
\ fern#smart#scheme(
\ "\<Plug>(fern-my-enter-bookmark)",
\ {
\ 'bookmark': "\<C-^>",
\ },
\ )
endfunction
Use https://github.com/lambdalisue/fern-hijack.vim
Use <C-w><C-p>
like
nmap <buffer> <Plug>(my-fern-open-and-stay) <Plug>(fern-action-open)<C-w><C-p>
Use :FernDo
to execute close
command after open.
Note that <Plug>(fern-close-drawer)
is a global mapping.
nnoremap <Plug>(fern-close-drawer) :<C-u>FernDo close -drawer -stay<CR>
nmap <buffer><silent> <Plug>(fern-action-open-and-close)
\ <Plug>(fern-action-open)
\ <Plug>(fern-close-drawer)
augroup my-fern-startup
autocmd! *
autocmd VimEnter * ++nested Fern ~/
augroup END
function! s:fern_preview_init() abort
nmap <buffer><expr>
\ <Plug>(fern-my-preview-or-nop)
\ fern#smart#leaf(
\ "\<Plug>(fern-action-open:edit)\<C-w>p",
\ "",
\ )
nmap <buffer><expr> j
\ fern#smart#drawer(
\ "j\<Plug>(fern-my-preview-or-nop)",
\ "j",
\ )
nmap <buffer><expr> k
\ fern#smart#drawer(
\ "k\<Plug>(fern-my-preview-or-nop)",
\ "k",
\ )
endfunction
augroup my-fern-preview
autocmd! *
autocmd FileType fern call s:fern_preview_init()
augroup END
" You need this otherwise you cannot switch modified buffer
set hidden
See https://github.com/lambdalisue/fern.vim/issues/193 for more detail
You can’t perform that action at this time.