15

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

syllogismos
  • 600
  • 2
  • 15
  • 39
  • 1
    Maybe the [nerdTree](http://www.vim.org/scripts/script.php?script_id=1658) is what you looking for despite its shortcomings. – complex857 Sep 03 '12 at 20:05
  • 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.. – syllogismos Sep 03 '12 at 20:08
  • 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) – complex857 Sep 03 '12 at 20:17
  • 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.. – syllogismos Sep 03 '12 at 20:22

2 Answers2

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).
romainl
  • 186,200
  • 21
  • 280
  • 313
5

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.

user21497
  • 1,061
  • 8
  • 9