Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

netrw

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..

like image 554
syllogismos Avatar asked Sep 03 '12 20:09

syllogismos


People also ask

How do I open Netrw files?

To launch netrw: Run vim with a directory as the command-line argument. :edit path/to/a/directory Enter (or :e <path/to/a/directory )

What is Netrw in Vim?

Netrw supports reading and writing files across networks. One may use urls for filenames or one may use netrw's Nread and Nwrite commands. Netrw as provided here supports remote and local directory browsing, and supports editing files across the network using a variety of methods.


2 Answers

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).
like image 70
romainl Avatar answered Sep 18 '22 18:09

romainl


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.

like image 25
user21497 Avatar answered Sep 17 '22 18:09

user21497