def run_alias(self, start, end, alias, clear=False): """Lookup a command given its alias and execute it.""" command = settings.get('aliases').get(alias) if command: self.run_command(start, end, command, clear) else: v.echo("'{}' alias not found".format(alias))
def run_command(self, start, end, command, clear=False): """To Run the command as the given command""" self.last_command = command if command and settings.get('bufname_expansion', bool): command = misc.expand_chars(command, '%', vim.current.buffer.name) if command and settings.get('selection_expansion', bool): command = misc.expand_chars( command, '@', '\r'.join(vim.current.buffer[start - 1:end])) if command and settings.get('function_expansion', bool): try: command = misc.expand_functions(command) except NameError: # the function does not exist v.echo('unknown function') return except ValueError: # bad arguments v.echo('bad arguments') return if not command or settings.get('always_clear_screen', bool): clear = True self.run(command, clear=clear)
def run_command(self, start, end, command, clear=False): """To Run the command as the given command""" self.last_command = command if command and settings.get('bufname_expansion', bool): command = misc.expand_chars(command, '%', vim.current.buffer.name) if command and settings.get('selection_expansion', bool): command = misc.expand_chars( command, '@', '\r'.join(vim.current.buffer[start-1:end])) if command and settings.get('function_expansion', bool): try: command = misc.expand_functions(command) except NameError: # the function does not exist v.echo('unknown function') return except ValueError: # bad arguments v.echo('bad arguments') return if not command or settings.get('always_clear_screen', bool): clear = True self.run(command, clear=clear)
def show_aliases(self): """To show all defined aliases.""" aliases = settings.get('aliases') if aliases: print('+ aliases') for i, alias in enumerate(aliases): conn = '└─ ' if i == len(aliases) - 1 else '├─ ' print(conn + alias + ': ' + aliases[alias]) else: v.echo('no aliases found')
def show_aliases(self): """To show all defined aliases.""" aliases = settings.get('aliases') if aliases: print('+ aliases') for i, alias in enumerate(aliases): conn = '└─ ' if i == len(aliases)-1 else '├─ ' print(conn + alias + ': ' + aliases[alias]) else: v.echo('no aliases found')
def run_last_command(self): """Execute the last executed command.""" if self.last_command: self.run_command(1, 1, self.last_command) else: v.echo('no last command to execute')