while ("im the true Vim master");

2008-10-12

Re: Python 2.6のライブラリリファレンスをVimから引くmapping

| 15:48

nmap {your-favorite-keyseq}  <Plug>(pydoc)
nnoremap <Plug>(pydoc)  :<C-u>call Pydoc()<CR><CR>
function! Pydoc()
  let _ = getpos('.')
    call search('\_s\zs\S', 'bcW')
    execute '!open ''http://docs.python.org/library/'.expand('<cword>').'.html\#'.expand('<cWORD>').''''
  call setpos('.', _)
endfunction

The original code has several bugs that are:

  • Can't look up a keyWORD if the cursor is at the beginning of the keyWORD.
  • Allow unnecessary remapping.
  • Move the cursor to the end of the keyWORD.

There is no valid/right example of Vim script around the world, eh.

トラックバック - http://vim.g.hatena.ne.jp/ka-nacht/20081012
最近のコメント
あわせて読みたいブログパーツ
AX