Trying to figure out how to use netrw (:E) correctly with :Rex and CTRL+O.

To reproduce, create 2 files in a /tmp/newdir directory.

mkdir /tmp/newdir
cd /tmp/newdir
echo "blabla 1" > file1.txt
echo "blabla 2" > file2.txt
vim file1.txt

Open file2.txt from netrw

Now in vim, open the netrw explorer with :E and press enter on file2.txt. Then choose to go back with CTRL+O, vim displays an empty buffer. Then if I press CTRL+O again, vim displays the buffer containing file1.txt. Here is the list of buffers displayed by :ls:

  1 %a   "file1.txt"                    line 1
  2 #    "NetrwTreeListing 1"           line 1
  4      "/tmp/newdir/file2.txt"        line 1

Close netrw with :Rex

A similar issue also happens when I close netrw with :Rex.

To reproduce:

vim file1.txt

In vim

:e file2.txt

Then press CTRL+O, vim displays an empty buffer, you need to press CTRL+O a second time to go to file1.txt. This is what is displayed by :ls

  1      "file1.txt"                    line 1
  2 #    "file2.txt"                    line 1
  5 %a   "NetrwTreeListing 2"           line 1


  • How can I have CTRL+O jump directly from the buffer with file2.txt to the buffer with file1.txt?
  • How do I prevent this empty NetrwTreeListing from appearing in the buffer list?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.