Created
July 20, 2010 05:15
-
-
Save hotoo/482560 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" cmdhere plugin for NERDTree. | |
" put this in $VIM/vimfiles/nerdtree_plugin/cmdhere.vim | |
" @author 闲耘™ (hotoo.cn[AT]gmail.com) | |
" @version 1.0 2010/07/20 | |
if exists("g:loaded_nerdtree_cmdhere") | |
finish | |
endif | |
let g:loaded_nerdtree_cmdhere = 1 | |
function! NERDTreeCmdhere() | |
let node = g:NERDTreeFileNode.GetSelected() | |
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 path = iconv(node.path.str({'escape':1}), &enc, code_page) | |
endif | |
if has('win32') | |
if node.path.isDirectory | |
exec ":!start cmd /c cmd /k pushd " . path | |
else | |
exec ":!start cmd /c cmd /k pushd " . path . "\\.." | |
endif | |
endif | |
endfunction | |
autocmd filetype nerdtree command! -nargs=0 -buffer Cmd :call NERDTreeCmdhere() | |
autocmd filetype nerdtree command! -nargs=0 -buffer Cmdhere :call NERDTreeCmdhere() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if has("win32") | |
" Open command(cmd) window. | |
command -nargs=0 Cmd :!start cmd | |
command -nargs=0 Cmdhere :!start cmd | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
安装:
用法:
在打开的文件或 NERDTree 中 执行 :Cmd 或 :Cmdhere 命令会启动 cmd 命令行,
起始目录为文件所在目录或 NERDTree 选中的目录。