Keep cursor in Netrw window when browsing files in VIM

8

3

I have a vertical split in VIM. On one side I open netrw (:E) to browse through some files/folders.

Although as soon as I press 'Return' to enter a folder, folder opens and cursor is moved into other window.

How can I keep the cursor in the netrw window?

Art

Posted 2012-01-12T02:57:03.383

Reputation: 921

Answers

7

Put this in your .vimrc,

let g:netrw_preview = 1

to configure vertical preview splits, then when the cursor is over the desired file, type p to open a preview window. To close the window, type Ctrl-W z.

The term used in vim for a window that's opened without the cursor moving to it is a "preview window". To find out more about this, see

:help netrw-preview
:help CTRL-W_z

or just

:help netrw

and browse the table of contents for other browsing commands and other netrw features.

garyjohn

Posted 2012-01-12T02:57:03.383

Reputation: 29 085

Thanks a lot, @garyjohn! I looked through the help before asking the question, but obviously failed to find that setting. – Art – 2012-01-12T05:20:23.160

Interesting, it works most of the time, but sometimes cursor still jumps back. Happens when I open 3 vertical splits and do :E in the right one - cursor jumps to the leftmost. – Art – 2012-02-03T00:31:53.550

That could be a bug. You can find the name and address of the author at the top of any of the netrw files and at ":help pi-netrw.txt". He is very helpful and responsive. I would send a description of the problem directly to him. – garyjohn – 2012-02-03T03:28:27.013

Thanks @garyjohn, I contacted the author. Hopefully he'll have some time to look into it. – Art – 2012-02-15T00:11:34.340

1

You could use :Lexplore, available with netrw v150 or later (its now up to v154, which you may get from http://www.drchip.org/astronaut/vim/index.html#NETRW).

user21497

Posted 2012-01-12T02:57:03.383

Reputation: 216

It may not be exactly what the OP asked, but it's exactly what I was looking for! Thank you for sharing! – James M. Lay – 2016-02-19T00:39:15.923