Skip to content

Open a file and keep tree open, but another hotkey for open file and close the tree afterwards #1984

@alex-courtis

Description

@alex-courtis

Discussed in #1980

Originally posted by mangelozzi February 9, 2023
I found there is an option: nvim-tree.actions.open_file.quit_on_open, but the problem with this it always closes the tree afterwards.
I wish to have o perform as default (keep the tree open after opening the file), but have <CR> open the buffer and close the tree.

Currently these seems to be the only options (tried them all):

`<CR>`            edit                open a file or folder; root will cd to the above directory
`o`
`<2-LeftMouse>`
`<C-e>`           edit_in_place       edit the file in place, effectively replacing the tree explorer
`O`               edit_no_picker      same as (edit) with no window picker

edit_in_place is similar but then I have 2 windows after opening the file, and have to go to the other window and close it.

Looking for something like this:

require("nvim-tree").setup({
    view = {
        mappings = {
            list = {
                { key = "<CR>", action = "quit_on_open" },
            },
        },
    },    
})
````</div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIAPI or EventPR pleasenvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciatedfeature request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions