nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua
Other
7.24k stars 609 forks source link

Visual Selection #2994

Open alex-courtis opened 5 days ago

alex-courtis commented 5 days ago

Discussed in https://github.com/nvim-tree/nvim-tree.lua/discussions/2993

Originally posted by **l00sed** November 9, 2024 First of all, thank you so much to the open source community, the plugin author, and plugin contributors. Nvim Tree is a fantastic plugin and part of my everyday workflow. 🌳 ### Some Background, Visual Selection The vim-centric way to delete multiple lines of text is to first `Shift-v`— visually select a full line of text. Next, with the visual line selection, I could navigate (`j` or `k`) to expand the selection area down or up, respectively. See below: https://github.com/user-attachments/assets/d33580ef-8841-4d20-b7db-c440973861ea I would love to mimic this behavior for selecting multiple files in Nvim Tree, using `` to visually select files or folders, then pressing `c` (for example, to copy) or `d` (to delete)— or running any action against that selection of files. Performing the selection this way, using the standard Vim visual selection, would feel like a seamless extension of normal buffer behavior. ### Example Scenario I want to delete several markdown files from a folder, `blog`. The files are in consecutive order, so I can `` to visually select the first file to delete (`car-hacking.mdx`) and then press `j` several times to expand the selection downward. Pressing `d` deletes the selected files. https://github.com/user-attachments/assets/a26a7290-b97f-4633-8fc7-6dd6db329059 Does anyone have an existing recipe that makes this behavior possible? Perhaps using the existing buffer marking (`m`) behavior as a way to integrate the key-bindings somehow? I suspect there are other people interested in this as well— or those who may have already found a solution. Funny enough, I found a [stack overflow](https://stackoverflow.com/questions/5745506/vim-modifiable-is-off) issue related to NERD Tree which was likely asked in the hope of achieving the same visual-selection behavior in this other Neovim tree-based file manager. **Other relevant discussions:** - [batch delete consecutive files (discussion#2677)](https://github.com/nvim-tree/nvim-tree.lua/discussions/2677)
alex-courtis commented 5 days ago

This feature would be incredible!

I've found myself naturally doing the same: <s-v> j j d That somewhat maps to marks m j m j m bd <s-v> j j y p to clipboard c j c j c p A repcipe to do this sort of mapping would be a bit clunky and failure prone, and will interfere with existing functionality.

A first class solution is desirable. We cannot use marks as they have use cases other than file manipulation. We can use the clipboard. As a start: perhaps:

As usual, pull requests are most gratefully appreciated, see CONTRIBUTING.md