vim - 如何向可视块中的所有行发出命令?
问题描述
如何在逐行可视块中的所有行上执行类似dtR
(删除直到遇到R
行中的)之类的操作,或者说,对于下一n
行?
漫长的故事
假设有以下代码:
L0 = Rotated_Shape((1, 0), (-1, 0), (-1, 1))
L90 = Rotated_Shape((0, -1), (0, 1), (1, 1))
L180 = Rotated_Shape((-1, 0), (1, 0), (1, -1))
L270 = Rotated_Shape((0, 1), (0, -1), (-1, -1))
O0 = Rotated_Shape((1, 0), (1, -1), (0, -1))
O90 = Rotated_Shape((0, -1), (-1, -1), (-1, 0))
O180 = Rotated_Shape((-1, 0), (-1, 1), (0, 1))
O270 = Rotated_Shape((0, 1), (1, 1), (1, 0))
S0 = Rotated_Shape((-1, 0), (0, -1), (1, -1))
S90 = Rotated_Shape((0, 1), (-1, 0), (-1, -1))
S180 = Rotated_Shape((1, 0), (0, 1), (-1, 1))
S270 = Rotated_Shape((0, -1), (1, 0), (1, 1))
T0 = Rotated_Shape((0, 1), (-1, 0), (1, 0))
T90 = Rotated_Shape((1, 0), (0, 1), (0, -1))
T180 = Rotated_Shape((0, -1), (1, 0), (-1, 0))
T270 = Rotated_Shape((-1, 0), (0, -1), (0, 1))
Z0 = Rotated_Shape((1, 0), (0, -1), (-1, -1))
Z90 = Rotated_Shape((0, -1), (-1, 0), (-1, 1))
Z180 = Rotated_Shape((-1, 0), (0, 1), (1, 1))
Z270 = Rotated_Shape((0, 1), (1, 0), (1, -1))
我现在正在修改这段代码,我希望所有这些行都成为等式(赋值)右侧的内容,即删除变量名、等号并只保留Rotated_Shape((...
部分。
我想完成这种特殊情况的最佳方法是搜索和替换正则表达式,但我不知道该怎么做的第一种方法是对它们中的每一个使用块可视化或线可视化模式并执行类似的东西dtR
(删除,直到你遇到R
行中的)。
解决方案
您可以使用视觉块突出显示这些行,然后使用:help 'normal'
.
选择后的最终结果如下所示::'<,'>normal dtR
您也可以缩写normal
为norm
.
推荐阅读
- linux - 打开 AppImage 什么都不做。我能做些什么?
- python - 将 list[0], list[1], list[2],... 压缩成一个简单的语句
- java - 如何解决“无法应用适配器”错误?
- spring-cloud-stream - 了解 Spring Cloud Stream Kafka 和 Spring Retry
- tsql - 创建/更新索引时减少 CPU 和读取的策略不是一个选项
- amazon-connect - 我想添加到我的 Amazon Connect 调度应用程序的功能
- voiceover - VoiceOver 是否有类似于 JAWS 的链接列表和标题列表?
- java - 我应该使用一两个队列吗?
- postgresql - 将字符串转换为日期,然后减去几个月
- mysql - 在MySql中替换变量文本值内的字符串