• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python vim.command函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vim.command函数的典型用法代码示例。如果您正苦于以下问题:Python command函数的具体用法?Python command怎么用?Python command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了command函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()")
开发者ID:andrey-starodubtsev,项目名称:simplenote.vim,代码行数:7,代码来源:SimplenoteUtilities.py


示例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()
开发者ID:let-def,项目名称:coquille,代码行数:28,代码来源:coquille.py


示例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)
开发者ID:borman,项目名称:clighter,代码行数:25,代码来源:refactor.py


示例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)
开发者ID:sancao2,项目名称:merlin,代码行数:25,代码来源:merlin.py


示例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]
  }))
开发者ID:TDaglis,项目名称:tern_for_vim,代码行数:27,代码来源:tern.py


示例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')
开发者ID:andreiglingeanu,项目名称:dotvim,代码行数:7,代码来源:aumercurial.py


示例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'])
开发者ID:vlmarek,项目名称:ConqueVlad,代码行数:29,代码来源:conque.py


示例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 ''
开发者ID:kianryan,项目名称:Omnisharp,代码行数:29,代码来源:OmniSharp.py


示例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)
开发者ID:kianryan,项目名称:Omnisharp,代码行数:7,代码来源:OmniSharp.py


示例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)))
开发者ID:jqno,项目名称:vim-orgmode,代码行数:7,代码来源:_vim.py


示例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])
开发者ID:goerz,项目名称:vim-hackernews,代码行数:7,代码来源:hackernews.py


示例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))
开发者ID:jqno,项目名称:vim-orgmode,代码行数:7,代码来源:_vim.py


示例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)
开发者ID:petersohn,项目名称:clighter,代码行数:25,代码来源:refactor.py


示例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")
开发者ID:andrey-starodubtsev,项目名称:simplenote.vim,代码行数:31,代码来源:SimplenoteUtilities.py


示例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) + ')')
开发者ID:octaloop,项目名称:dotfiles,代码行数:35,代码来源:conque_sole.py


示例16: lookupAllUserTypes

def lookupAllUserTypes():
    js = getResponse('/lookupalltypes')
    if (js != ''):
        response = json.loads(js)
        if (response != None):
            vim.command("let s:allUserTypes = '%s'" % (response['Types']))
            vim.command("let s:allUserInterfaces = '%s'" % (response['Interfaces']))
开发者ID:kianryan,项目名称:Omnisharp,代码行数:7,代码来源:OmniSharp.py


示例17: main

def main():
    binary = 'clang-rename'
    if vim.eval('exists("g:clang_rename_path")') == "1":
        binary = vim.eval('g:clang_rename')

    # Get arguments for clang-rename binary.
    offset = int(vim.eval('line2byte(line("."))+col(".")')) - 2
    if offset < 0:
        print >> sys.stderr, '''Couldn\'t determine cursor position.
                                Is your file empty?'''
        return
    filename = vim.current.buffer.name

    new_name_request_message = 'type new name:'
    new_name = vim.eval("input('{}\n')".format(new_name_request_message))

    # Call clang-rename.
    command = [binary,
               filename,
               '-i',
               '-offset', str(offset),
               '-new-name', str(new_name)]
    # FIXME: make it possible to run the tool on unsaved file.
    p = subprocess.Popen(command,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
    stdout, stderr = p.communicate()

    if stderr:
        print stderr

    # Reload all buffers in Vim.
    vim.command("bufdo edit")
开发者ID:bbannier,项目名称:clang-tools-extra-1,代码行数:33,代码来源:clang-rename.py


示例18: draw

    def draw(self):
    
        # get current buffer!
        b = utils.get_buffer(self.buffer_name)

        # set to markdown syntax for now
        vim.command("set filetype=markdown")

        # append title
        b.append("## %s" % self.repo)
        b.append("")
        
        for i in self.issues:
            issue_string = "%s. \"%s\" " % (i[0], i[1])

            if len(i[5]) > 0:
                 issue_string += "#%s " % ",".join(i[5])
            
            if not (i[2] == github.user()["login"]):
                issue_string += "@%s " % i[2]
            if not (i[3] == "open"):
                issue_string += i[3]
            
            # add labels if they exist
            b.append(issue_string)

        # delete first line
        vim.command("1delete _")
开发者ID:jonmorehouse,项目名称:vimhub,代码行数:28,代码来源:issue_list.py


示例19: dirty

def dirty(repo, filepath):
    if not hasattr(repo, '__getitem__'):
        vim_throw('statuns', repo.path)
    m=match.match(None, None, [filepath], exact=True)
    status=repo.status(match=m, unknown=True)
    if any(status[:-2]):
        vim.command('let r=1')
开发者ID:andreiglingeanu,项目名称:dotvim,代码行数:7,代码来源:aumercurial.py


示例20: _switch_to

	def _switch_to(cls, bufname, vim_commands=None):
		u"""
		Swicht to the buffer with bufname.

		A list of vim.commands (if given) gets executed as well.

		TODO: this should be extracted and imporved to create an easy to use
		way to create buffers/jump to buffers. Otherwise there are going to be
		quite a few ways to open buffers in vimorgmode.
		"""
		cmds = [u'botright split org:%s' % bufname,
				u'setlocal buftype=nofile',
				u'setlocal modifiable',
				u'setlocal nonumber',
				# call opendoc() on enter the original todo item
				u'nnoremap <silent> <buffer> <CR> :exec "py ORGMODE.plugins[u\'Agenda\'].opendoc()"<CR>',
				u'nnoremap <silent> <buffer> <TAB> :exec "py ORGMODE.plugins[u\'Agenda\'].opendoc(switch=True)"<CR>',
				u'nnoremap <silent> <buffer> <S-CR> :exec "py ORGMODE.plugins[u\'Agenda\'].opendoc(split=True)"<CR>',
				# statusline
				u'setlocal statusline=Org\\ %s' % bufname
				]
		if vim_commands:
			cmds.extend(vim_commands)
		for cmd in cmds:
			vim.command(cmd.encode(u'utf-8'))
开发者ID:iverson4664,项目名称:vim_plugins,代码行数:25,代码来源:Agenda.py



注:本文中的vim.command函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vim.eval函数代码示例发布时间:2022-05-26
下一篇:
Python vim.bindeval函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap