oli*_*bre 3 vim keyboard-shortcuts insertion
我经常忘记如何以视觉块模式插入并再次阅读答案Shift+i.
为什么小写i在视觉模式下不起作用?
技术原因是什么?
因为i并且a在所有视觉模式中不像正常模式那样行为的原因是i并且a用于将选择扩展到文本对象.正如您所见:help visual-operators:
4. Operating on the Visual area
The operators that can be used are:
~ switch case
d delete
c change (4)
y yank
> shift right (4)
< shift left (4)
! filter through external command (1)
= filter through 'equalprg' option command (1)
gq format lines to 'textwidth' length (1)
The objects that can be used are:
aw a word (with white space)
iw inner word
aW a WORD (with white space)
iW inner WORD
as a sentence (with white space)
is inner sentence
ap a paragraph (with white space)
ip inner paragraph
ab a () block (with parenthesis)
ib inner () block
aB a {} block (with braces)
iB inner {} block
at a <tag> </tag> block (with tags)
it inner <tag> </tag> block
a< a <> block (with <>)
i< inner <> block
a[ a [] block (with [])
i[ inner [] block
a" a double quoted string (with quotes)
i" inner double quoted string
a' a single quoted string (with quotes)
i' inner simple quoted string
a` a string in backticks (with backticks)
i` inner string in backticks
Additionally the following commands can be used:
: start Ex command for highlighted lines (1)
r change (4)
s change
C change (2)(4)
S change (2)
R change (2)
x delete
D delete (3)
X delete (2)
Y yank (2)
p put
J join (1)
U make uppercase
u make lowercase
^] find tag
I block insert
A block append
Run Code Online (Sandbox Code Playgroud)
因此,只需在可视块模式下使用block insert大写I或block append大写A命令即可.
该命令在光标位置之前i插入。在可视块模式下,光标位置(通常)代表所选内容的右下角,并且光标位置包含在块中。
因此, 的语义i不匹配,这就是为什么它被排除在 Vim 实现之外(添加它可能只是对源代码进行简单的一行更改)。语义确实匹配I(在任何文本之前插入)和(在任何文本之后A插入),这就是它们在可视块模式下可用的原因。