一个用Python给Vim做的插件,PythonVim做插件,[Python]代码fu


[Python]代码

function! Google()python << EOM# coding=utf-8import vimimport reimport webbrowserline = vim.current.linerow,col =  vim.current.window.cursorprint colstart = end = colwhile True:    if line[start].isspace():        break    start-=1while True:    if line[end].isspace():        break    end+=1word = line[start+1:end]if not word or word.isspace():    print 'You cannot call Google in a space position!'else:    try:        url = 'http://www.google.com/search?q='+word        webbrowser.open(url)        print 'Google : %s' % word    except:        print 'Failed! : Cannot access Google!'EOMendfunctioncommand Google :call Google()

评论关闭