I used nmap <silent> <f2> :NERDTreeToggle<cr>
to toggle nerdtree window. How can I do the same with netrw?
nerdtree window is not shown in the buffer list(:ls
). netrw is listed in the buffer list. How can I make it not listed?
:bn
command works but :bp
command does not work in the netrw window. Is this a bug?
The 'Vexplore' command opens a vertical directory browser. You can build on this by adding the following code to your .vimrc file to toggle the vertical browser with Ctrl-E (for example):
" Toggle Vexplore with Ctrl-E
function! ToggleVExplorer()
if exists("t:expl_buf_num")
let expl_win_num = bufwinnr(t:expl_buf_num)
if expl_win_num != -1
let cur_win_id = win_getid()
exec expl_win_num . 'windo close'
let prev_win_num = win_id2win(cur_win_id)
if prev_win_num != 0
exec prev_win_num . 'wincmd w'
endif
endif
unlet t:expl_buf_num
else
exec '1wincmd w'
Vexplore
let t:expl_buf_num = bufnr("%")
endif
endfunction
map <silent> <C-E> :call ToggleVExplorer()<CR>
The code above tries to open the Explorer window on the left hand side of the screen at all times; I use it with multiple split vertical windows open.
[OPTIONAL] You might like to add the following lines to your .vimrc to improve the browsing experience:
" Hit enter in the file browser to open the selected
" file with :vsplit to the right of the browser.
let g:netrw_browse_split = 4
let g:netrw_altv = 1
" Change directory to the current buffer when opening files.
set autochdir