Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 5 down vote accepted

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.

share|improve this answer
    
Thanks a lot, @garyjohn! I looked through the help before asking the question, but obviously failed to find that setting. – Art Jan 12 '12 at 5:20
    
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 Feb 3 '12 at 0:31
    
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 Feb 3 '12 at 3:28
    
Thanks @garyjohn, I contacted the author. Hopefully he'll have some time to look into it. – Art Feb 15 '12 at 0:11

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

share|improve this answer
    
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 Feb 19 at 0:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .