如何重复插入字符,直到下一行?


11

说我有这样的评论:

//This is a comment

我想这样:

//*****************
//This is a comment
//*****************

有没有简单的方法可以重复插入字符,直到下一行/上一行?


要生成这样的模式,您可能需要使用代码片段引擎。您可以阅读此问题,以比较代码片段插件。例如,您可以使用ultisnips ibox<key>This is a comment(其中<key>是定义为触发摘要的键),这将创建一个this is a comment内部尺寸合适的盒子。
statox

17a*<Esc>在类似的情况下,您可以使用这种方法,您知道所需的字符数,或者确切的数字并不重要,因为它不必与另一行均匀对齐。)
Aaron Thoma

Answers:



2

在场合°:

插入模式映射以复制相邻行的其余部分

" Insert the rest of the line below the cursor.
" Mnemonic: Elevate characters from below line
inoremap <A-e> 
    \<Esc>
    \jl
        \y$
    \hk
        \p
        \a
" Insert the rest of the line above the cursor.
" Mnemonic:  Y depicts a funnel, through which the above line's characters pour onto the current line.
inoremap <A-y> 
    \<Esc>
    \kl
        \y$
    \hj
        \p
        \a

在插入模式下从相邻行复制单个字符

…内置:help i_CTRL-E

CTRL-E   Insert the character which is below the cursor.
CTRL-Y   Insert the character which is above the cursor.

°不是问题文本的含义,而是其他用户可能在此处查找的内容,从当前问题标题“插入直到下一行”。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.