本文整理汇总了Python中vim.command函数的典型用法代码示例。如果您正苦于以下问题:Python command函数的具体用法?Python command怎么用?Python command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了command函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transform_to_scratchbuffer
def transform_to_scratchbuffer(self):
""" transforms the current buffer into a scratchbuffer """
vim.command("call s:ScratchBuffer()")
vim.command("setlocal nocursorline")
vim.command("setlocal buftype=acwrite")
vim.command("setlocal nomodified")
vim.command("au! BufWriteCmd <buffer> call s:UpdateNoteFromCurrentBuffer()")
示例2: coq_rewind
def coq_rewind(steps=1):
if coqtop is None:
print("Error: Coqtop isn't running. Are you sure you called :CoqLaunch?")
return
global encountered_dots, info_msg
request = ET.Element('call')
request.set('val', 'rewind')
request.set('steps', str(steps))
send_cmd(request)
response = get_answer()
if response is None:
vim.command("call coquille#KillSession()")
print('ERROR: the Coq process died')
return
if response.get('val') == 'good':
additional_steps = response.find('int') # should never be none
nb_removed = steps + int(additional_steps.text)
encountered_dots = encountered_dots[:len(encountered_dots) - nb_removed]
else:
info_msg = "[COQUILLE ERROR] Unexpected answer:\n\n%s" % ET.tostring(response)
refresh()
示例3: __vim_multi_replace
def __vim_multi_replace(locs, old, new, prompt_level):
if locs is None:
return
pattern = ""
for line, column, bufname in locs:
if bufname is None or bufname != vim.current.buffer.name:
continue
if pattern:
pattern += "\|"
pattern += "\%" + str(line) + "l" + "\%>" + str(
column - 1) + "c\%<" + str(column + len(old)) + "c" + old
if not pattern:
return
cmd = "%s/" + pattern + "/" + new + "/gI"
if prompt_level >= 2:
cmd = cmd + "c"
vim.command(cmd)
示例4: replace_buffer_portion
def replace_buffer_portion(start, end, txt):
encoding = vim_encoding()
start_line = start["line"] - 1
b = vim.current.buffer
fst_line = b[start_line]
lst_line = b[end["line"] - 1]
prefix = fst_line[0 : start["col"]]
suffix = lst_line[end["col"] : len(lst_line)]
del b[start_line : end["line"]]
txt = prefix.decode(encoding) + txt + suffix.decode(encoding)
lines = txt.split("\n")
lines.reverse()
nb_lines = 0
for line in lines:
nb_lines += 1
b[start_line:0] = [line.encode(encoding)]
# Properly reindent the modified lines
vim.current.window.cursor = (start["line"], 0)
vim.command("call feedkeys('%d==', 'n')" % nb_lines)
示例5: tern_ensureCompletionCached
def tern_ensureCompletionCached():
cached = vim.eval("b:ternLastCompletionPos")
curRow, curCol = vim.current.window.cursor
curLine = vim.current.buffer[curRow - 1]
if (curRow == int(cached["row"]) and curCol >= int(cached["end"]) and
curLine[0:int(cached["end"])] == cached["word"] and
(not re.match(".*\\W", curLine[int(cached["end"]):curCol]))):
return
data = tern_runCommand({"type": "completions", "types": True, "docs": True},
{"line": curRow - 1, "ch": curCol})
if data is None: return
completions = []
for rec in data["completions"]:
completions.append({"word": rec["name"],
"menu": tern_asCompletionIcon(rec.get("type")),
"info": tern_typeDoc(rec) })
vim.command("let b:ternLastCompletion = " + json.dumps(completions))
start, end = (data["start"]["ch"], data["end"]["ch"])
vim.command("let b:ternLastCompletionPos = " + json.dumps({
"row": curRow,
"start": start,
"end": end,
"word": curLine[0:end]
}))
示例6: diffToBuffer
def diffToBuffer(*args, **kwargs):
ui=CaptureToBuf()
dodiff(ui, *args, **kwargs)
if len(vim.current.buffer)>1 and vim.current.buffer[-1] == '':
vim.current.buffer[-1:]=[]
else:
vim.command('setlocal binary noendofline')
示例7: csi_clear_line
def csi_clear_line(self, csi):
""" Process the line clear escape sequence. """
# this escape defaults to 0
if len(csi['vals']) == 0:
csi['val'] = 0
# 0 means cursor right
if csi['val'] == 0:
self.screen[self.l] = self.screen[self.l][0:self.c - 1]
# 1 means cursor left
elif csi['val'] == 1:
self.screen[self.l] = ' ' * (self.c) + self.screen[self.l][self.c:]
# clear entire line
elif csi['val'] == 2:
self.screen[self.l] = ''
# clear colors
if csi['val'] == 2 or (csi['val'] == 0 and self.c == 1):
buffer_line = self.get_buffer_line(self.l)
if buffer_line in self.color_history:
for syn in self.color_history[buffer_line]:
vim.command('syn clear ' + syn['name'])
示例8: getResponse
def getResponse(endPoint, additionalParameters=None, timeout=None ):
parameters = {}
parameters['line'] = vim.eval('line(".")')
parameters['column'] = vim.eval('col(".")')
parameters['buffer'] = '\r\n'.join(vim.eval("getline(1,'$')")[:])
parameters['filename'] = vim.current.buffer.name
if(additionalParameters != None):
parameters.update(additionalParameters)
if(timeout == None):
timeout=int(vim.eval('g:OmniSharp_timeout'))
host = vim.eval('g:OmniSharp_host')
if vim.eval('exists("b:OmniSharp_host")') == '1':
host = vim.eval('b:OmniSharp_host')
target = urlparse.urljoin(host, endPoint)
parameters = urllib.urlencode(parameters)
proxy = urllib2.ProxyHandler({})
opener = urllib2.build_opener(proxy)
try:
response = opener.open(target, parameters, timeout)
vim.command("let g:serverSeenRunning = 1")
return response.read()
except Exception as e:
vim.command("let g:serverSeenRunning = 0")
return ''
示例9: getTestCommand
def getTestCommand():
mode = vim.eval('a:mode')
parameters = {}
parameters['Type'] = mode
response = json.loads(getResponse('/gettestcontext', parameters))
testCommand = "let s:testcommand = '%(TestCommand)s'" % response
vim.command(testCommand)
示例10: echo
def echo(message):
u"""
Print a regular message that will not be visible to the user when
multiple lines are printed
"""
for m in message.split(u'\n'):
vim.command(u_encode((u':echo "%s"' % m)))
示例11: recall_pos
def recall_pos():
marks = vim.eval("g:hackernews_marks")
m = hex(vim.current.buffer[0])
if m in marks:
mark = marks[m]
vim.current.window.cursor = (int(mark[0]), int(mark[1]))
vim.command("set syntax=%s" % mark[2])
示例12: echoe
def echoe(message):
u"""
Print an error message. This should only be used for serious errors!
"""
# probably some escaping is needed here
for m in message.split(u'\n'):
vim.command(u_encode(u':echoerr "%s"' % m))
示例13: __vim_multi_replace
def __vim_multi_replace(locs, old, new, prompt):
if not locs:
return
pattern = ""
for line, column, bufname in locs:
if not bufname or bufname != vim.current.buffer.name:
continue
if pattern:
pattern += r'\|'
pattern += r'\%' + str(line) + 'l' + r'\%>' + str(
column - 1) + r'c\%<' + str(column + len(old)) + 'c' + old
if not pattern:
return
cmd = '%s/' + pattern + '/' + new + '/gI'
if prompt >= 2:
cmd = cmd + 'c'
vim.command(cmd)
示例14: version_of_current_note
def version_of_current_note(self, version=None):
""" retrieve a specific version of current note """
note_id = self.get_current_note()
try:
current_version = self.note_version[note_id]
buffer = vim.current.buffer
if version is None:
# If no args then just print version of note
print("Displaying note ID %s version %s" % (note_id, current_version))
else:
if (buffer.options["modified"] == False):
if version == "0":
note, status = self.simplenote.get_note(note_id)
if status == 0:
buffer[:] = list(map(lambda x: str(x), note["content"].split("\n")))
# Need to set as unmodified so can continue to browse through versions
vim.command("setlocal nomodified")
print("Displaying most recent version of note ID %s" % note_id)
else:
note, status = self.simplenote.get_note(note_id, version)
if status == 0:
buffer[:] = list(map(lambda x: str(x), note["content"].split("\n")))
# Need to set as unmodified so can continue to browse through versions
vim.command("setlocal nomodified")
print("Displaying note ID %s version %s. To restore, :Simplenote -u, to revert to most recent, :Simplenote -v" % (note_id, version))
else:
print("Error fetching note data. Perhaps that version isn't available.")
else:
print("Save changes before trying to show another version")
except KeyError:
print("This isn't a Simplenote")
示例15: set_cursor
def set_cursor(self, line, column):
""" Update cursor position in Vim buffer """
logging.debug('setting cursor at line ' + str(line) + ' column ' + str(column))
# handle offset
line += self.offset
# shift cursor position to handle concealed text
if self.enable_colors and self.color_mode == 'conceal':
if line - 1 in self.color_conceals:
for c in self.color_conceals[line - 1]:
if c < column:
column += 7
else:
break
logging.debug('column is now ' + str(column))
# figure out line
buffer_line = line
if buffer_line > len(self.buffer):
for l in range(len(self.buffer) - 1, buffer_line):
self.buffer.append('')
# figure out column
real_column = column
if len(self.buffer[buffer_line - 1]) < real_column:
self.buffer[buffer_line - 1] = self.buffer[buffer_line - 1] + ' ' * (real_column - len(self.buffer[buffer_line - 1]))
# python version is occasionally grumpy
try:
vim.current.window.cursor = (buffer_line, real_column - 1)
except:
vim.command('call cursor(' + str(buffer_line) + ', ' + str(real_column) + ')')