+ -
当前位置:首页 → 问答吧 → 一个用Python给Vim做的插件

一个用Python给Vim做的插件

时间:2011-01-20

来源:互联网

  1. function! Google()
  2. python << EOM
  3. # coding=utf-8

  4. import vim
  5. import re
  6. import webbrowser

  7. line = vim.current.line
  8. row,col =  vim.current.window.cursor
  9. print col
  10. start = end = col
  11. while True:
  12.         if line[start].isspace():
  13.                 break
  14.         start-=1
  15. while True:
  16.         if line[end].isspace():
  17.                 break
  18.         end+=1
  19. word = line[start+1:end]
  20. if not word or word.isspace():
  21.         print 'You cannot call Google in a space position!'
  22. else:
  23.         try:
  24.                 url = 'http://www.google.com/search?q='+word
  25.                 webbrowser.open(url)
  26.                 print 'Google : %s' % word
  27.         except:
  28.                 print 'Failed! : Cannot access Google!'

  29. EOM
  30. endfunction


  31. command Google :call Google()
复制代码

作者: 阳光boyer   发布时间: 2011-01-20

楼主没说用途

作者: hlsd665   发布时间: 2011-01-20

具体啥用处?

作者: 2gua   发布时间: 2011-01-20