Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
" open fiel in system file explorer plugin for NERDTree.
" put this in $VIM/vimfiles/nerdtree_plugin/fileexplorer.vim
" @author 闲耘™ (hotoo.cn[AT]gmail.com)
" @version 1.0 2010/07/20
if exists("g:loaded_nerdtree_fileexplorer")
finish
endif
let g:loaded_nerdtree_fileexplorer = 1
autocmd filetype nerdtree nmap <buffer> <F6> :call FileExplorer(g:NERDTreeFileNode.GetSelected().path.str({'escape':1}))<cr>
autocmd filetype nerdtree command! -nargs=0 -buffer Explor :call FileExplorer(g:NERDTreeFileNode.GetSelected().path.str({'escape':1}))
autocmd filetype nerdtree command! -nargs=0 -buffer Explorer :call FileExplorer(g:NERDTreeFileNode.GetSelected().path.str({'escape':1}))
function! FileExplorer(path)
if a:path == ""
let p = expand("%:p")
else
let p = a:path
endif
if executable("chcp")
let code_page = 'cp' . matchstr(system("chcp"), "\\d\\+")
else
" If chcp doesn't work, set its value manually here.
let code_page = 'cp936'
endif
if has('win32') && !has('win32unix') && (&enc!=code_page)
let p = iconv(p, &enc, code_page)
endif
exec ":!start explorer /select, " . p
" Open Explorer Tree.
"exec ":!start explorer /e,/select, " . p
endfunction
if has("win32")
" Open Windows Explorer and Fouse current file.
" %:p:h " Just Fold Name.
nmap <F6> :call FileExplorer("")<cr>
imap <F6> <C-o><F6>
command -nargs=0 Explor :call FileExplorer("")
command -nargs=0 Explorer :call FileExplorer("")
endif
Owner

hotoo commented Jul 20, 2010

安装:

  1. FileExplorer.vim 放至 $VIM/vimfiles/nerdtree_plugin/ 目录下;
  2. FileExplorer.vimrc 添加到 vimrc 中。

用法:
在打开的文件或 NERDTree 中按 、执行 :Explor 或 :Explorer
会在文件资源管理器中定位目标文件/夹。
如果希望同时展开资源管理器的树型结构,启用 explorer 的 /e 参数即可。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment