vim:执行编辑器命令列表 [英] vim: Executing a list of editor commands

查看:65
本文介绍了vim:执行编辑器命令列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

vim中是否有一种方法可以提供编辑器命令列表?我想执行一系列全局"命令,并且这些命令有一些模式.因此,理想情况下,我想生成命令列表(使用正则表达式搜索和替换),然后运行它们,而不必键入每个命令.

Is there a way in vim to give a list of editor commands? I want to execute a series of 'global' commands, and there is some pattern to the commands. So I would ideally like to generate the list of commands (using regex search & substitute), and then run them, instead of having to type in each command.

谢谢!高拉夫

推荐答案

(更新:s/buffer/register/g)

如果可以将要运行的所有命令移入寄存器,则执行寄存器?

If you can yank all of the commands you want to run into a register, then execute the register ?

http://www.bo.infn.it/alice/alice-doc/mll-doc/linux/vi-ex/node24.html

例如,如果您有以下文件:

For example, if you have a file like:

abc
def
ghi
dd
dd

然后做

:g/dd/y A

这将用dd替换所有行,并将其追加到寄存器a中

This yanks all lines with dd and appends into register a

然后,如果您位于文件的第一行,则键入:

Then if you are on the first line of the file, and type:

@a

然后将删除2行,文件应如下所示:

Then 2 lines will now be deleted, and the file should look like:

ghi
dd
dd

这篇关于vim:执行编辑器命令列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆