Skip to content

<Tab> key no longer opens directories, only previews, after recent update #2027

Answered by alex-courtis
haakonfp asked this question in Q&A
Discussion options

You must be logged in to vote

When I tried remapping <Tab> to some random action, like tabnew, it actually opens directories again (but also opens new tabs instead of previewing files, which is not what I want).

How would I remap this to get my original functionality of previewing files and opening/closing directories?

That was actually a bug; "preview" would open file when it was on a directory, in this case expanding the directory.

Here's a function you can map to achieve this behaviour via action_cb:

local function preview_or_toggle_dir(node)
  local api = require("nvim-tree.api")

  if node.type == "file" or node.type == "link" then
    api.node.open.preview(node)
  else
    api.node.open.edit(node)
  end
end

P.…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@haakonfp
Comment options

Answer selected by haakonfp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants