@woshichuanqilz
2015-11-15T03:13:40.000000Z
字数 1149
阅读 1224
Vim
- Two Keys here
- 1. Read the output from the cmd line use the statement "r !echo hello" you will get the output in the current window
- 2. Redirect the output to the buffer window.
execute "split" fnamescape(bufname)
setlocal buftype=nofile
setlocal nobuflisted
" Press leader r and the word under the curor will be search in the python help
nnoremap <leader>r :<C-u>execute "!start cmd /k python C:\\Python27\\Lib\\pydoc.py " . expand("<cword>")<CR>
"Enter :Pyhelp "SearchWord" in the command line you will get the help about the word in a new buffer.
command! -nargs=1 -bar Pyhelp :call ShowPydoc(<f-args>)
function! ShowPydoc(what)
let bufname = a:what . ".pydoc"
" check if the buffer exists already
if bufexists(bufname)
let winnr = bufwinnr(bufname)
if winnr != -1
" if the buffer is already displayed, switch to that window
execute winnr "wincmd w"
else
" otherwise, open the buffer in a split
execute "sbuffer" bufname
endif
else
" create a new buffer, set the nofile buftype and don't display it in the
" buffer list
execute "split" fnameescape(bufname)
setlocal buftype=nofile
setlocal nobuflisted
" read the output from pydoc
let l:cmd = "r !python C:\\Python27\\Lib\\pydoc.py " . a:what
" execute "r !" . shellescape(s:pydoc_path, 1) . " " . shellescape(a:what, 1)
execute cmd
endif
" go to the first line of the document
1
endfunction