See [help if_pyth.txt]. Below is a more elaborate example. Put the following code in your vimrc: python << EOL import vim # Do not say 'from vim import *' because that # will delete builtin function eval. def EvaluateCurrentLine(*args): cur_str = vim.current.line action, symb = None, None for i in args: if i in ["r","p"]: action = i else: symb = i try: start = cur_str.rindex(symb)+len(symb) except: start = 0 result = eval(cur_str[start:],globals()) if action == "r": vim.current.line = cur_str[:start]+str(result) else: print result EOL command -narg=* PyEv python EvaluateCurrentLine()
Attributes | Values |
---|---|
rdfs:label |
|
rdfs:comment |
|
Version |
|
dbkwik:vim/property/wikiPageUsesTemplate | |
Previous |
|
Category |
|
Author |
|
Complexity |
|
Created |
|
ID |
|
NEXT |
|
Rating |
|
abstract |
|