nmap <silent> <f2> :NERDTreeToggle<cr>来切换书呆子窗口。缓冲区列表(:ls)中没有显示如何对netrw?:bn命令,但是:bp命令在netrw窗口中不工作。这是个bug吗?发布于 2011-04-12 14:33:28
“opens”命令打开垂直目录浏览器。您可以在此基础上将以下代码添加到.vimrc文件中,以便使用Ctrl切换垂直浏览器(例如):
" 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_nr = winnr()
exec expl_win_num . 'wincmd w'
close
exec cur_win_nr . 'wincmd w'
unlet t:expl_buf_num
else
unlet t:expl_buf_num
endif
else
exec '1wincmd w'
Vexplore
let t:expl_buf_num = bufnr("%")
endif
endfunction
map <silent> <C-E> :call ToggleVExplorer()<CR>上面的代码试图在任何时候打开屏幕左侧的Explorer窗口;我在打开多个拆分垂直窗口时使用它。
可选,您可能希望在.vimrc中添加以下行以提高浏览体验:
" 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发布于 2014-04-14 20:03:40
从netrw v150开始,有:Lexplore,它将在左侧切换netrw窗口。
发布于 2014-05-28 19:26:19
我只是对Nick's solution做了一些改进,修复了:
打开100%高的窗口(独立于splits)
:Lexplore窗口)在左侧打开窗口,右侧的:Lexplore!在
将这些行放在.vimrc的末尾:
com! -nargs=* -bar -bang -complete=dir Lexplore call netrw#Lexplore(<q-args>, <bang>0)
fun! Lexplore(dir, right)
if exists("t:netrw_lexbufnr")
" close down netrw explorer window
let lexwinnr = bufwinnr(t:netrw_lexbufnr)
if lexwinnr != -1
let curwin = winnr()
exe lexwinnr."wincmd w"
close
exe curwin."wincmd w"
endif
unlet t:netrw_lexbufnr
else
" open netrw explorer window in the dir of current file
" (even on remote files)
let path = substitute(exists("b:netrw_curdir")? b:netrw_curdir : expand("%:p"), '^\(.*[/\\]\)[^/\\]*$','\1','e')
exe (a:right? "botright" : "topleft")." vertical ".((g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize) . " new"
if a:dir != ""
exe "Explore ".a:dir
else
exe "Explore ".path
endif
setlocal winfixwidth
let t:netrw_lexbufnr = bufnr("%")
endif
endfun建议的行为类似于NERDTree的选项:
" absolute width of netrw window
let g:netrw_winsize = -28
" do not display info on the top of window
let g:netrw_banner = 0
" tree-view
let g:netrw_liststyle = 3
" sort is affecting only: directories on the top, files below
let g:netrw_sort_sequence = '[\/]$,*'
" use the previous window to open file
let g:netrw_browse_split = 4https://stackoverflow.com/questions/5006950
复制相似问题