2

If I open a file in a current directory using netrw and then reopen the netrw using :Sexplore the netrw window opens below (I have splitbelow set), but the cursor remains in the file being edited and I cannot move to the netrw window using CTRL-W combinations.

Am I doing something wrong or is this a bug?

Steps to reproduce

  • run vim .
  • netrw opens, highlight a file in the current directory (let's say test.txt) and press Return, file test.txt opens
  • run :Sexplore cmd
  • netrw opens below but the cursor remains in the file opened previously.

My .vimrc

set nocompatible
set splitbelow

VIM version

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec  8 2015 23:11:08)
MacOS X (unix) version
Included patches: 1-944

This is how it looks like:vim error

Maciej Wozniak
  • 1,174
  • 15
  • 27

1 Answers1

2

I cannot reproduce with version 154a (use :echo g:loaded_netrwPlugin to check your netrw version).

Try with the latest version.


Edit:

It is possible that the problem is cause by some other plugin interference or settings. You could try following the approach described at Vim FAQ 2.5:

2.5. I have a "xyz" (some) problem with Vim. How do I determine it is a problem with my setup or with Vim? / Have I found a bug in Vim?

First, you need to find out, whether the error is in the actual runtime files or any plugin that is distributed with Vim or whether it is a simple side effect of any configuration option from your .vimrc or .gvimrc. So first, start vim like this:

vim -u NONE -U NONE -N -i NONE

This starts Vim in nocompatible mode (-N), without reading your viminfo file (-i NONE), without reading any configuration file (-u NONE for not reading .vimrc file and -U NONE for not reading a .gvimrc file) or even plugin.

(...)

If the error does not occur when starting Vim this way, then the problem is either related to some plugin of yours or some setting in one of your local setup files. You need to find out, what triggers the error, you try starting Vim this way:

vim -u NONE -U NONE -N

If the error occurs, the problem is your .viminfo file. Simply delete the viminfo file then. If the error does not occur, try:

vim -u ~/.vimrc --noplugin -N -i NONE

This will simply use your .vimrc as configuration file, but not load any plugins. If the error occurs this time, the error is possibly caused by some configuration option inside your .vimrc file. Depending on the length of your vimrc file, it can be quite hard to trace the origin within that file.

The best way is to add :finish command in the middle of your .vimrc. Then restart again using the same command line. If the error still occurs, the bug must be caused because of a setting in the first half of your .vimrc. If it doesn't happen, the problematic setting must be in the second half of your .vimrc. So move the :finish command to the middle of that half, of which you know that triggers the error and move your way along, until you find the problematic option. If your .vimrc is 350 lines long, you need at a maximum 9 tries to find the offending line (in practise, this can often be further reduced, since often lines depend on each other).

Obviously you will have to load netrw manually (which can be done by sourcing plugin/netrwPlugin.vim -- if you are using some plugin manager you will have to move the plugin to ~/.vim/ or change your runtime path due to the autoload functions) and set nocompatible and splitbelow.

Actually there is an adapted version of this procedure in :help netrw-debug:

Step 2: assuming that you've installed the latest version of netrw, check that your problem is really due to netrw. Create a file called netrw.vimrc with the following contents:

set nocp  
so $HOME/.vim/plugin/netrwPlugin.vim 

Then run netrw as follows:

vim -u netrw.vimrc --noplugins [some path here] 

Perform whatever netrw commands you need to, and check that the problem is still present. This procedure sidesteps any issues due to personal .vimrc settings and other plugins. If the problem does not appear, then you need to determine what setting in your .vimrc is causing the conflict with netrw or which plugin.

Step 3: If the problem still is present, then get a debugging trace from netrw:

(...)

mMontu
  • 8,983
  • 4
  • 38
  • 53
  • After updating to 155f it still doesn't work. Do you have `splitbelow` enabled? – Maciej Wozniak Dec 09 '15 at 15:42
  • @MaciejWozniak yes, I had the `splitbelow` enabled. Is there any chance it is plugin interference? I've included that on the answer. – mMontu Dec 09 '15 at 15:59
  • Thanks @mMontu but it didn't help :(. What I did was: remove (backup) `~/.vim/`, `.vimrc`, `.viminfo`, then create a new `~/.vim/` with only latest netrw installed, and empty `.vimrc` with only `nocompatible` and `splitbelow` set. Same problem :(. What OS are you using? Maybe it's Mac-related. – Maciej Wozniak Dec 09 '15 at 16:32
  • Tried applying your latest solution (netrw.vimrc) - still no success. While reproducing this issue are you starting vim by `vim .` ? And is the file you're editing in the current directory ? – Maciej Wozniak Dec 09 '15 at 16:36
  • 1
    @MaciejWozniak I'm on linux, maybe it is Mac-related. And yes, I started with `vim .` and edited a file on the same directory. You should follow the third step on `:help netrw-debug` and open a bug, the plugin author usually answers very fast. – mMontu Dec 09 '15 at 17:57
  • I just tried this with a mac using both vi (huge, v7.4.663) and mvim (7.4.258) along with netrw v155g, and was unable to duplicate the issue. I used the -u netrw.vimrc approach. – user21497 Jan 12 '16 at 17:45