how to make netrw in vim work like solution explorer in visual studio
Asked Answered
D

2

16

okay, i will make this more clear here.. say i have the directory listing in a vertical split window, along with the file i'm editing..

i can go from one split to the other using Ctrl+w and open files in the file listing using netrw plugin in four ways.. using return key, v, o, t..

with return key, it opens in the current(netrw) split window.. with v, it creates a new vertical split..(same with o(horizontal split), t(new tab))

but i want the file to be opened in the other split that is already there, where i do all the editing..instead of opening a new split.. i hope my question is clear.. say by typing a command, the highlighted file will open in the editing split instead of the netrw split.. there must be some easy solution to this.. or can someone tell me the best way to use netrw.. i will try to adapt..

Drugget answered 3/9, 2012 at 20:2 Comment(4)
Maybe the nerdTree is what you looking for despite its shortcomings.Bridgehead
im happy with netrw.. but it seems like there must be some key combination to achieve this.. and i'm missing something.. if there is no solution i will get used to this.. or just install nerdtree plugin.. are you sure nerdtree solves this..Drugget
I'm not sure since I'm not a regular visual studio user, but nerdtree seem to use the last non-nerdtree split when i open a file (also has i/o/t and the others)Bridgehead
forget visual studio.. i explained what i want in the description.. what happens is when i click enter on a file in the tree.. it opens right there.. instead i want it to open in an already present split window, with the tree split being intact..Drugget
C
24

The answer is in the doc: :h netrw. As usual.

You are looking for P:

To edit a file or directory in the previously used (last accessed) window (see
:he CTRL-W_p), press a "P".  If there's only one window, then the one window
will be horizontally split (above/below splitting is controlled by
g:netrw_alto, and its initial size is controlled by g:netrw_winsize).

If there's more than one window, the previous window will be re-used on
the selected file/directory.  If the previous window's associated buffer
has been modified, and there's only one window with that buffer, then
the user will be asked if s/he wishes to save the buffer first (yes,
no, or cancel).
Cloninger answered 3/9, 2012 at 20:32 Comment(1)
i did search for it.. but didn't find it, i found it now i'm trying to do this for a while now.. thank you..Drugget
L
6

Another approach: use :let g:netrw_chgwin=2 (or whatever window number you prefer). Subsequent selection of a file in netrw will then use that window for editing.

Lakenyalaker answered 18/4, 2014 at 19:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.