在VIM中使用GOOGLE进行搜索或者翻译,vimgoogle,[Python]代码py


[Python]代码

python << EOM#coding = utf-8def google_it(word):    import re    import webbrowser    if not word or word.isspace():        print 'there is no word under the cursor'    else:        try:            url = 'http://www.google.com/search?q='+word            webbrowser.open(url)        except:            print 'cannot access google!'def google_translate_it(word):    import re    import webbrowser    if not word or word.isspace():        print 'there is no word under the cursor!'    else:        try:            url = 'http://translate.google.cn/#en|zh-CN|'+word+'%0A'            webbrowser.open(url)        except:            print 'cannot access google!'EOMfunction! Google()python << EOM#coding = utf-8import vimpy_word = vim.eval("expand(\"<cword>\")")print py_wordgoogle_it(py_word)EOMendfunctionfunction! GoogleTranslate()python << EOM#coding = utf-8import vimpy_word = vim.eval("expand(\"<cword>\")")print py_wordgoogle_translate_it(py_word)EOMendfunctioncommand GOOGLE :call Google()command GOOGLETRANSLATE :call GoogleTranslate()

评论关闭