VIM 逐块插入 [英] VIM Blockwise Insert

查看:42
本文介绍了VIM 逐块插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 VIM 中所选文本块的开头插入一个哈希值(红宝石注释).我在可视模式下选择了行,但如何对所有行执行相同的操作?

I would like to insert a hash at the beginning of a selected block of text in VIM (ruby comment). I selected the lines in Visual Mode, but how do I perform the same operation to all lines?

推荐答案

您有两个主要选择:

  • 以块可视模式(ctrl-v)选择,然后使用 I 沿整个块的左侧插入相同的内容.同样A追加;参见 blockwise 操作符.

  • Select in block visual mode (ctrl-v), then use I to insert the same thing along the left side of the entire block. Similarly A appends; see blockwise operators.

选择正常视觉 (v) 或视觉 (V) 模式下的行,然后对所有这些行运行相同的命令,例如 s/^/#/ 或 <代码>普通I#.键入 : 当您有视觉选择时会自动使用视觉选择作为行范围(由 '<,'> 表示).

Select the lines in normal visual (v) or visual line (V) mode, then run the same command on all of them, for example s/^/# / or normal I#. Typing : while you have a visual selection automatically uses the visual selection as the line range (denoted by '<,'>).

这篇关于VIM 逐块插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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