def surround_text(header=None, footer=None): """Surround selected text with header and footer """ # header, footer): if not header: header = vim.prompt("header? :") if not footer: footer = vim.prompt("footer? :") cr = anything.range new_text = [header] + cr[:] + [footer] cr[:] = None vim.insert(cr.start,new_text)
def analyze_code(how="vsplit"): tmp_xml = "/tmp/output.xml" tmp_py = "/tmp/output.py" src = vim.current.buffer.name tchecker_cmd = "tchecker.py -o " + tmp_xml + " " + src annot_cmd = "annot.py " + tmp_xml + " " + src os.system(tchecker_cmd) ret = os.popen(annot_cmd).read().split("\n") vim.command("%s %s" % (how, tmp_py)) clear_buffer() vim.insert(0, ret)
def insert_eval_python(): """HTML escape for selection""" cr = anything.range let = [ repr(eval(exp)) for exp in cr[:] ] vim.insert(cr.end+1, let)
def transform_selection(f): cr = anything.range new_text = [ f(line) for line in cr[:]] cr[:] = None vim.insert(cr.start, new_text) vim.normal("V%dj" % (len(new_text) - 1) )