Search code examples
vimnetrw

Netrw open in active directory


I want Netrw (:e) to open in same folder of the file I'm currently looking at. For example,

A
...B
   ...file1.txt
   ...file2.txt

If I run :e inside of folder A, navigate into folder B, open up file1.txt, and then run :e again, I would like Netrw to open up with B as the directory, and not A.


Solution

  • Found my answer in this Vimcast. :Explore or :E will open up Netrw in the current file's directory. I got an ambiguous use of user-defined command error at first when I tried to use :E, but this SO answer helped fix that. I just had to add this command to my .vimrc, command! -nargs=* -bar -bang -count=0 -complete=dir E Explore <args>. :E only works if there are no other possible commands that start with :E.