可以在VIM中翻译单词的python代码,vim单词python代码,在Python语言的学习
可以在VIM中翻译单词的python代码,vim单词python代码,在Python语言的学习
在Python语言的学习过程中,一定会使用到编辑器。VIM也在其中,今天的代码就是有关VIM的。需要达到的效果是,在VIM中直接调用浏览器搜索或翻译当前光标下单词的一段代码,简单的就是说可以在VIM中翻译单词的python代码。
需要注意的是VIM必须内建PYTHON(放入.vimrc 文件中即可)
用google搜索哦,也可以换其它翻译的。
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!'EOM#www.iplaypy.comfunction! 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()
编橙之家文章,
相关内容
- 可视化SVM分类器开源实现的python代码,svmpython,如下的
- Python将多个txt文本合并为一个文本的代码,pythontxt,编橙
- 一个简单的猜字游戏python代码,python代码,import rando
- Python pexpect包应用之快速多线程ping测试,pythonpexpect,#
- Python方法完成加速器后台程序设置源码示例,python加速
- Python各种排序方法汇总,python排序汇总,这是我做为学生
- Python 井字棋三连棋游戏代码,python井字棋代码,Python 井
- 遇到python编码错误要怎么解决,遇到python编码错误,这只
- Python3.X绿色精简版IDLE,python3.xidle,这是适用于Python3
- Django模板中css与javascript的应用,djangocss,学习Python一定
评论关闭