原文
a = 2
b = 33
c = 456
所需文字
print("a = 2")
print("b = 33")
print("c = 456")
这个例子只是为了说明预期的结果。它与我程序的目标无关。
如何print("
在每行的开头和每行")
的末尾追加内容?当我使用可视模式时,Ctrl-V
我可以执行第一个操作,但不能执行第二个操作,因为行长不同。
您可以使用宏。将光标放在第一行的任意位置,然后键入
qaIprint("<esc>A")<esc>jq
这分解如下
qa # start recording macro a
I # enter insert mode at the beginning of the line
print(" # enter text
<esc> # leave insert mode
A # enter insert mode at the end of the line
") # enter text
<esc> # leave insert mode
jq # move to the next line and stop recording
然后,您可以通过键入重复运行此命令@a
。如果知道要更改的行数,则可以附加一个计数。例如:50@a
将运行50次并修改接下来的50行。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句