-
-
Notifications
You must be signed in to change notification settings - Fork 616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
:NvimTreeToggle
- toggle file explorer in all tabs
#1493
Comments
Thanks so much for the tips @erikw! You actually helped me solve multiple issues 🎉 Setting lua <<EOF
require("nvim-tree").setup({
open_on_tab = true,
})
EOF Your global open / close snippet was great too, I modified it slightly to toggle when typing function! NvimTreeToggleAll()
let current_tab = tabpagenr()
if g:nvim_tree_open
tabdo NvimTreeClose
let g:nvim_tree_open = 0
else
tabdo NvimTreeOpen
let g:nvim_tree_open = 1
endif
execute 'tabnext' current_tab
endfunction
let g:nvim_tree_open = 0
nnoremap nt :call NvimTreeToggleAll()<CR> Note that if you open a directory instead of a file, your nvim-tree will already by open but the script above globally sets it as closed initially. So the first time you hit |
Quick update: you can use It should evaluate to true ✔️ in the following:
Should be false ❌ for:
The full script might look something like: function! NvimTreeToggleAll()
let current_tab = tabpagenr()
if g:nvim_tree_open
tabdo NvimTreeClose
let g:nvim_tree_open = 0
else
tabdo NvimTreeOpen
let g:nvim_tree_open = 1
endif
execute 'tabnext' current_tab
endfunction
let g:nvim_tree_open = 0
if isdirectory(argv(0))
let g:nvim_tree_open = 1
endif
nnoremap nt :call NvimTreeToggleAll()<CR> |
Nice! Do you want to share that one as a Recipe? |
Sounds good to me @alex-courtis! I just added a recipe here: https://github.com/nvim-tree/nvim-tree.lua/wiki/Recipes#toggle-nvim-tree-open--closed-with-nt Just let me know if I did that wrong or if you're looking for something else! Thanks! |
I would like the file browser to act globally meaning that it's either hidden in all tabs or visible in all tabs.
By setting
I can get halfway there. The problem is that there's no way that I've found to close the open all file explorers.
Is there already a way to do accomplish this (closing all open file explorers)? Otherwise this could be a separate command
:NvimTreeToggleGlobally
that overrides individual tab statuses and force closes or opens the file explorer in all tabs.Update
I found that I can make a global close and open by using two different keyboard shortcuts.
But the best would be a global toggle like described above!
The text was updated successfully, but these errors were encountered: