5

Problem:

  1. Open Vim
  2. Type :Lex to open netrw file explorer and open a file in a vertical split using v
  3. As you can see in the image below, the space allocated to the split is tiny.
  4. This only happens on the first time netrw file explorer is opened. If I close the file explorer and follow step 2 again and open a file again using v, I get the expected behaviour as shown in the 2nd image below.

.vimrc settings:

let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_altv = 1
let g:netrw_winsize = 25
noremap <C-x> :Lex<CR>
autocmd FileType netrw setl bufhidden=wipe

Actual behaviour: enter image description here

Desired behaviour: enter image description here

doctopus
  • 5,349
  • 8
  • 53
  • 105

2 Answers2

0

You need to select an open directory as working

add in your expression: %:p:h

  • % - current file name
  • :p - expand to full path
  • :h - head (last path component removed)

ex:

nnoremap <leader>dd :Lexplore %:p:h<CR> 
0

:Iexplore sets the g:netrw_chegwin variable so that all subsequent :Explore split commands will also open the selected buffer on the same window as :Lexplore

If you use :Lex, the variable g:netrw_chegwin gets set to 2, and even after you close the :Flex window, the variable remains set.

So if, for example you use :Sex after using :Lex, the file that you select will open in the window that was being used by :Lex, which is probably not what you want.

To make :Explore splits behave as they normally do, you can reset by:

let g:netrw_chgwin = -1