简体   繁体   English

在vim中进行垂直编辑 - 替换文本

[英]vertical editing in vim - replacing text

If I want type the same text in many lines I use: ctrl-v , then I , typing, esc 如果我想在许多行中键入相同的文本我使用: ctrl-v ,然后I ,输入, esc

so I can make fast changes from: 所以我可以快速改变:

aaa
bbb
ccc
ddd
...

to: 至:

123aaa
123bbb
123ccc
123ddd
...

but it doesnt work if I use del while typing. 但如果我在打字时使用del ,它就无法工作。 and i must do column replace in 2 steps: removing unwanted characters from column ( ctrl-v + x ), then typing like above. 我必须分2步执行列替换:从列中删除不需要的字符( ctrl-v + x ),然后键入如上所示。

is it possible to improve editing and do it in single operation? 是否有可能改进编辑并在单一操作中完成? sth like: ......喜欢:

aaa
bbb
ccc
ddd
...

to: 至:

123aa
123bb
123cc
123dd
...

You can select the first column and do c123 : 您可以选择第一列并执行c123

[a]aa
[b]bb
[c]cc
[d]dd

c123<Esc>

123aa
123bb
123cc
123dd

In visual-block mode, s is equivalent to c . 在视觉块模式中, s相当于c You can also use d and x to cut the selection, rx to replace every character in the selection with x and of course y to yank the whole block. 您还可以使用dx来剪切选区, rxx替换选区中的每个字符,当然还有y来抽取整个块。 You can also use p to paste but you need to be careful with what you paste. 您也可以使用p来粘贴,但是您需要小心粘贴的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM