Python vim.command() Examples
The following are 30
code examples of vim.command().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
vim
, or try the search function
.
Example #1
Source File: repeater.py From pappy-proxy with MIT License | 6 votes |
def update_buffers(req): b1_id = int(vim.eval("s:b1")) b1 = vim.buffers[b1_id] b2_id = int(vim.eval("s:b2")) b2 = vim.buffers[b2_id] # Set up the buffers set_buffer_content(b1, req.full_message()) if req.response is not None: set_buffer_content(b2, req.response.full_message()) # Save the port, ssl, host setting vim.command("let s:dest_port=%d" % req.dest_port) vim.command("let s:dest_host='%s'" % escape(req.dest_host)) if req.use_tls: vim.command("let s:use_tls=1") else: vim.command("let s:use_tls=0")
Example #2
Source File: vim_ipython.py From sos with BSD 3-Clause "New" or "Revised" License | 6 votes |
def run_this_line(dedent=False): line = vim.current.line if dedent: line = line.lstrip() if line.rstrip().endswith('?'): # intercept question mark queries -- move to the word just before the # question mark and call the get_doc_buffer on it w = vim.current.window original_pos = w.cursor new_pos = (original_pos[0], vim.current.line.index('?')-1) w.cursor = new_pos if line.rstrip().endswith('??'): # double question mark should display source # XXX: it's not clear what level=2 is for, level=1 is sufficient # to get the code -- follow up with IPython team on this get_doc_buffer(1) else: get_doc_buffer() # leave insert mode, so we're in command mode vim.command('stopi') w.cursor = original_pos return msg_id = send(line) print_prompt(line, msg_id)
Example #3
Source File: cpsm.py From cpsm with Apache License 2.0 | 6 votes |
def ctrlp_match(): """ Deprecated interface that gets arguments by calling vim.eval() and returns outputs by calling vim.command(). Kept for Denite. Use ctrlp_match_with() or cpsm_py.ctrlp_match() in new code. """ # TODO: a:regex is unimplemented. results, regexes = ctrlp_match_with( items=_vim_eval("a:items"), query=_vim_eval("a:str"), limit=int(_vim_eval("a:limit")), mmode=_vim_eval("a:mmode"), ispath=int(_vim_eval("a:ispath")), crfile=_vim_eval("a:crfile"), highlight_mode=_vim_eval("g:cpsm_highlight_mode"), match_crfile=int(_vim_eval("s:match_crfile")), max_threads=int(_vim_eval("g:cpsm_max_threads")), query_inverting_delimiter=_vim_eval("g:cpsm_query_inverting_delimiter"), regex_line_prefix=_vim_eval("s:regex_line_prefix"), unicode=int(_vim_eval("g:cpsm_unicode"))) vim.command("let s:results = [%s]" % ",".join( map(_escape_and_quote, results))) vim.command("let s:regexes = [%s]" % ",".join( map(_escape_and_quote, regexes)))
Example #4
Source File: vimplayer.py From pycopia with Apache License 2.0 | 6 votes |
def normalize(): newbuf = [""] for line in vim.current.buffer: line = line.strip() if line: top = newbuf.pop() if top: top += " " + line else: top = "\t"+line newbuf.append(top) elif newbuf[-1]: newbuf.append("") vim.current.buffer[:] = newbuf vim.command("set ff=dos") ### initialization and setup ####
Example #5
Source File: mediawiki_editor.py From vim-mediawiki-editor with MIT License | 6 votes |
def mw_diff(article_name): article_name = infer_default(article_name) s = site() vim.command("diffthis") vim.command( "leftabove vsplit %s" % fn_escape(article_name + " - REMOTE") ) vim.command( "setlocal buftype=nofile bufhidden=delete nobuflisted" ) vim.command("set ft=mediawiki") vim.current.buffer[:] = ( s.Pages[article_name].text().split("\n") ) vim.command("diffthis") vim.command("set nomodifiable")
Example #6
Source File: init.py From vim-gdscript3 with MIT License | 6 votes |
def gdscript_complete(): util.clear_cache() completer.clear_completions() line = util.get_line()[0:util.get_cursor_col_num() - 1] syn_attr = util.get_syn_attr() if syn_attr == "gdComment": return elif syn_attr == "gdString": completer.complete_paths() elif re.match("(\s*class\s+\w+\s+)?extends\s*", line): completer.complete_class_names(classes.EXTENDABLE) elif re.match("export\(\s*", line): completer.complete_class_names(classes.EXPORTABLE) elif re.match("\s*func", line): completer.complete_method_signatures() elif line and line[-1] == ".": completer.complete_dot() else: completer.complete_script(include_globals=True) completions = completer.get_completions() vim.command("let gdscript_completions = " + str(completions))
Example #7
Source File: repeater.py From pappy-proxy with MIT License | 6 votes |
def set_up_windows(): reqid = vim.eval("a:2") storage_id = vim.eval("a:3") msg_addr = vim.eval("a:4") vim.command("let s:storage_id=%d" % int(storage_id)) # Get the left buffer vim.command("new") vim.command("only") b2 = vim.current.buffer vim.command("let s:b2=bufnr('$')") # Vsplit new file vim.command("vnew") b1 = vim.current.buffer vim.command("let s:b1=bufnr('$')") print msg_addr comm_type, comm_addr = msg_addr.split(":", 1) set_conn(comm_type, comm_addr) with ProxyConnection(kind=comm_type, addr=comm_addr) as conn: # Get the request req = conn.req_by_id(reqid, int(storage_id)) update_buffers(req)
Example #8
Source File: vimconda.py From vim-conda with MIT License | 5 votes |
def conda_activate(env_name, env_path, envs_root): """ This function performs a complete (internal) conda env activation. There are two primary actions: 1. Change environment vars $PATH and $CONDA_DEFAULT_ENV 2. Change EMBEDDED PYTHON sys.path, for jedi-vim code completion :return: None """ # This calls a vim function that will # change the $PATH and $CONDA_DEFAULT_ENV vars vim.command("call s:CondaActivate('{}', '{}', '{}')".format(env_name, env_path, envs_root)) # Obtain sys.path for the selected conda env # TODO: Perhaps make this flag a Vim option that users can set? ADD_ONLY_SITE_PKGS = True if ADD_ONLY_SITE_PKGS: new_paths = [os.path.join(env_path, 'lib', 'site-packages')] else: new_paths = obtain_sys_path_from_env(env_path) # Insert the new paths into the EMBEDDED PYTHON sys.path. # This is what jedi-vim will use for code completion. # TODO: There is another way we could do this: instead of a full reset, we could # remember what got added, and the reset process could simply remove those # things; this approach would preserve any changes the user makes to # sys.path inbetween calls to s:CondaChangeEnv()... # TODO: I found out that not only does jedi-vim modify sys.path for # handling VIRTUALENV (which is what we do here), but it also looks like # there is a bug in that the same venv path can get added multiple times. # So it looks like the best policy for now is to continue with the # current design. sys.path = new_paths + _conda_py_globals['reset_sys_path'] # Modify sys.path for Jedi completion if not msg_suppress: print('Activated env: {}'.format(env_name))
Example #9
Source File: vim_ipython.py From sos with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_doc_buffer(level=0): # empty string in case vim.eval return None vim.command("let isk_save = &isk") # save iskeyword list vim.command("let &isk = '@,48-57,_,192-255,.'") word = vim.eval('expand("<cword>")') or '' vim.command("let &isk = isk_save") # restore iskeyword list doc = get_doc(word, level) if len(doc) ==0: echo(repr(word)+" not found","Error") return # documentation buffer name is same as the query made to ipython vim.command('new '+word) vim.command('setlocal modifiable noro') # doc window quick quit keys: 'q' and 'escape' vim.command('nnoremap <buffer> q :q<CR>') # Known issue: to enable the use of arrow keys inside the terminal when # viewing the documentation, comment out the next line vim.command('nnoremap <buffer> <Esc> :q<CR>') # and uncomment this line (which will work if you have a timoutlen set) #vim.command('nnoremap <buffer> <Esc><Esc> :q<CR>') b = vim.current.buffer b[:] = None b[:] = doc vim.command('setlocal nomodified bufhidden=wipe') #vim.command('setlocal previewwindow nomodifiable nomodified ro') #vim.command('set previewheight=%d'%len(b))# go to previous window vim.command('resize %d'%len(b)) #vim.command('pcl') #vim.command('pedit doc') #vim.command('normal! ') # go to previous window if level == 0: # use the ReST formatting that ships with stock vim vim.command('setlocal syntax=rst') else: # use Python syntax highlighting vim.command('setlocal syntax=python')
Example #10
Source File: minimap.py From vim-minimap with MIT License | 5 votes |
def closeminimap(): minimap = getmmwindow() src = vim.current.window if minimap: vim.current.window = minimap # clear the minimap autocmds setmmautocmd(True) vim.command(":quit!") # try the last window, but sometimes this one was already closed # (ex. tagbar toggle) which will lead to an exception try: vim.current.window = src except: vim.current.window = vim.windows[0]
Example #11
Source File: minimap.py From vim-minimap with MIT License | 5 votes |
def showminimap(): minimap = getmmwindow() # If the minimap window does not yet exist, create it if not minimap: # Save the currently active window to restore it later src = vim.current.window vim.command(":botright vnew %s" % MINIMAP) # make the new buffer 'temporary' vim.command(":setlocal buftype=nofile bufhidden=wipe noswapfile nobuflisted") # make ensure our buffer is uncluttered vim.command(":setlocal nonumber norelativenumber nolist nospell") # set all autocmds in a group setmmautocmd() minimap = vim.current.window minimap.width = WIDTH # fixed size vim.command(":set wfw") # Restore the active window vim.current.window = src vim.command(":call minimap#UpdateMinimap()")
Example #12
Source File: minimap.py From vim-minimap with MIT License | 5 votes |
def setmmautocmd(clear = False): vim.command(":augroup minimap_group") vim.command(":autocmd!") if not clear: # Properly close the minimap when quitting VIM (ie, when minimap is the last remaining window vim.command(":autocmd WinEnter <buffer> if winnr('$') == 1|q|endif") vim.command(':autocmd CursorMoved,CursorMovedI,TextChanged,TextChangedI,BufWinEnter * MinimapUpdate') vim.command(":augroup END")
Example #13
Source File: vimconda.py From vim-conda with MIT License | 5 votes |
def conda_startup_env(): """ Get conda startup env This is happening at script startup. It looks like a conda env was already activated before launching vim, so we need to make the required changes internally. """ envname = vim.eval('g:conda_startup_env') # Need to get the root "envs" dir in order to build the # complete path the to env. roots = [os.path.dirname(x) for x in get_envs() if envname == os.path.split(x)[-1]] if len(roots) > 1: print('Found more than one matching env, ' 'this should never happen.') elif len(roots) == 0: print('\nCould not find a matching env in the list. ' '\nThis probably means that you are using a local ' '\n(prefix) Conda env.' '\n ' '\nThis should be fine, but changing to a named env ' '\nmay make it difficult to reactivate the prefix env.' '\n ') vim.command('let g:conda_startup_was_prefix = 1') else: root = roots[0] envpath = os.path.join(root, envname) # Reset the env paths back to root # (This will also modify sys.path to include the site-packages # folder of the Python on the system $PATH) conda_deactivate() # Re-activate. conda_activate(envname, envpath, root)
Example #14
Source File: vimconda.py From vim-conda with MIT License | 5 votes |
def vim_conda_runpyshell(cmd): """ Run python external python command """ return check_output('python -c "{}"'.format(cmd), shell=True, executable=os.getenv('SHELL'), stdin=PIPE, stderr=PIPE).decode('utf-8')
Example #15
Source File: vimconda.py From vim-conda with MIT License | 5 votes |
def vim_conda_runshell(cmd): """ Run external shell command """ return check_output(cmd, shell=True, executable=os.getenv('SHELL'), stdin=PIPE, stderr=PIPE).decode('utf-8')
Example #16
Source File: vimconda.py From vim-conda with MIT License | 5 votes |
def conda_deactivate(): """ This does the reset. """ # Resets $PATH and $CONDA_DEFAULT_ENV vim.command('call s:CondaDeactivate()') # Resets sys.path (embedded Python) _conda_py_globals['syspath'] = copy.copy(sys.path) # Remember the unmodified one sys.path = _conda_py_globals['reset_sys_path'] # Modify sys.path for Jedi completion # Re-apply the sys.path from the shell Python # The system python path may not already be part of # the embedded Python's sys.path. This fn will check. insert_system_py_sitepath() if not msg_suppress: print('Conda env deactivated.')
Example #17
Source File: tq_common_lib.py From thesaurus_query.vim with Apache License 2.0 | 5 votes |
def vim_command(command): """ wrapper for Vim command, do nothing if session is Vim independent """ if independent_session: return None vim.command(command)
Example #18
Source File: vim_ipython.py From sos with BSD 3-Clause "New" or "Revised" License | 5 votes |
def echo(arg,style="Question"): try: vim.command("echohl %s" % style) vim.command("echom \"%s\"" % arg.replace('\"','\\\"')) vim.command("echohl None") except vim.error: print("-- %s" % arg)
Example #19
Source File: padawan.py From padawan.vim with MIT License | 5 votes |
def RemovePlugin(self, plugin): composerCommand = composer + ' global remove' command = '{0} {1}'.format( composerCommand, plugin ) stream = subprocess.Popen( command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) def onRemoved(): subprocess.Popen( '{0}'.format( cli + ' plugin remove ' + plugin ), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ).wait() self.RestartServer() return editor.notify("Plugin removed") def LogRemoving(): retcode = stream.poll() if retcode is not None: return onRemoved() line = str(stream.stdout.readline()) editor.log(line) return True editor.callAfter(1e-4, LogRemoving)
Example #20
Source File: padawan.py From padawan.vim with MIT License | 5 votes |
def notify(self, message): vim.command("echom '%s'" % self.prepare(message))
Example #21
Source File: padawan.py From padawan.vim with MIT License | 5 votes |
def log(self, message): vim.command("echo '%s'" % self.prepare(message))
Example #22
Source File: padawan.py From padawan.vim with MIT License | 5 votes |
def sendRequest(self, command, params, data=''): addr = str(server_addr) + "/"+str(command)+"?" + urlencode(params) request = Request(addr, headers={ "Content-Type": "plain/text" }, data = quote_plus(data).encode("utf-8")) response = urlopen( request, timeout=timeout ) data = json.load(response) if "error" in data: raise ValueError(data["error"]) return data
Example #23
Source File: padawan.py From padawan.vim with MIT License | 5 votes |
def start(self): command = '{0} > {1}/logs/server.log'.format( server_command, padawanPath ) subprocess.Popen( command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
Example #24
Source File: mediawiki_editor.py From vim-mediawiki-editor with MIT License | 5 votes |
def mw_read(article_name): if isinstance(article_name, six.binary_type): article_name = article_name.decode("utf-8") s = site() vim.current.buffer[:] = ( s.Pages[article_name].text().split("\n") ) vim.command("set ft=mediawiki") vim.command( "let b:article_name = '%s'" % sq_escape(article_name) )
Example #25
Source File: mediawiki_editor.py From vim-mediawiki-editor with MIT License | 5 votes |
def get_from_config_or_prompt( var, prompt, password=False, text="" ): c = get_from_config(var) if c is not None: return c else: resp = input(prompt, text=text, password=password) vim.command( "let %s = '%s'" % (var, sq_escape(resp)) ) return resp
Example #26
Source File: mediawiki_editor.py From vim-mediawiki-editor with MIT License | 5 votes |
def input(prompt, text="", password=False): vim.command("call inputsave()") vim.command( "let i = %s('%s', '%s')" % ( ("inputsecret" if password else "input"), sq_escape(prompt), sq_escape(text), ) ) vim.command("call inputrestore()") return vim.eval("i")
Example #27
Source File: token.py From DyeVim with MIT License | 5 votes |
def RemoveMatch( self, wid ): matchId = self._matchIds.pop( wid, 0 ) if matchId != 0: vim.command( 'call matchdelete({0})'.format( matchId ) )
Example #28
Source File: vimsupport.py From DyeVim with MIT License | 5 votes |
def PostVimWarning( message ): # Displaying a new message while previous ones are still on the status line # might lead to a hit-enter prompt or the message appearing without a # newline so we do a redraw first. vim.command( 'redraw' ) vim.command( 'echohl WarningMsg' ) vim.command( "echom '{0}'".format( message ) ) vim.command( 'echohl None' )
Example #29
Source File: dyevim.py From DyeVim with MIT License | 5 votes |
def _InitializeCurrentFiletypeIfNeeded( self ): ft = vimsupport.GetCurrentFileType() if ft not in self._initialized_filetypes: try: vim.command('call dyevim#ft#' + ft + '#Setup()') except: pass self._initialized_filetypes.add( ft )
Example #30
Source File: sourcetrail.py From vim-sourcetrail with MIT License | 5 votes |
def update_buffer(cls): """update""" if cls.inst().__server is None: cls.inst().start_server() print("Vim was not listening to Sourcetrail. Vim is listening now.") print("Try to send again from Sourcetrail.") else: if cls.inst().__update: # Must clear the __update flag before "e!" due to autocmd nesting cls.inst().__update = False vim.command("e! " + cls.inst().__file) vim.current.window.cursor = (cls.inst().__row, cls.inst().__col)