有时我想跨多行编辑某个可视文本块。
例如,我会取一个看起来像这样的文本:
name
comment
phone
email
让它看起来像这样
vendor_name
vendor_comment
vendor_phone
vendor_email
现在我要做的是…
Select all 4 row lines of a block by pressing V and then j four times. Indent with >. Go back one letter with h. Go to block visual mode with Ctrlv. Select down four rows by pressing j four times. At this point you have selected a 4x1 visual blocks of whitespace (four rows and one column). Press C. Notice this pretty much indented to the left by one column. Type out a " vendor_" without the quote. Notice the extra space we had to put back. Press Esc. This is one of the very few times I use Esc to get out of insert mode. Ctrlc would only edit the first line. Repeat step 1. Indent the other way with <.
如果单词前至少有一列空白,我就不需要缩进。如果我不需要用c清除可视块,我就不需要空白。
但是如果我必须清除,那么是否有一种方法来做我上面所做的而不创建所需的缩进空白?
还有为什么一次编辑多行只能通过退出插入模式与Esc在Ctrlc?
这里有一个更复杂的例子:
name = models.CharField( max_length = 135 )
comment = models.TextField( blank = True )
phone = models.CharField( max_length = 135, blank = True )
email = models.EmailField( blank = True )
to
name = models.whatever.CharField( max_length = 135 )
comment = models.whatever.TextField( blank = True )
phone = models.whatever.CharField( max_length = 135, blank = True )
email = models.whatever.EmailField( blank = True )
在这个例子中,我将在.上执行垂直可视块,然后在插入模式下重新插入它,即输入.whatever..希望现在你能看到这种方法的缺点。我只能选择一列在垂直位置相同的文本。