为什么在可视块模式下小写字母 [i] 不起作用?

4
我经常忘记如何在可视化块模式下插入,并重新阅读答案Shift+i
正如Honghe.Wu在他的评论中所问:

为什么小写的i在可视模式下不起作用?

这是技术原因是什么?
2个回答

6

ia 在所有视图模式下不像正常模式那样工作的原因是它们被用于扩展选择到文本对象。如您在: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                    

所以在可视块模式下,只需使用大写的I进行块插入或使用大写的A进行块追加


5
i命令在光标位置之前插入内容。在可视块模式下,光标位置(通常)代表选择的右下角,并且光标位置包括在块中。
因此,i的语义不匹配,这就是为什么Vim实现中没有它的原因(将其添加可能只需要一行简单的源代码更改)。对于I(在任何文本之前插入)和A(在任何文本之后插入),它们的语义确实匹配,这就是为什么在可视块模式下它们是可用的。

非常好的解释。出于某种原因,我以前从未质疑过它,只是习惯了可用的键。 - Prince Goulash
2
还有一个事实,当处于任何可视模式时,“I”会启动文本对象。 - Ben

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接