如果您的Vim设置在'formatoptions'
中包含'r'(默认值),它将在插入模式下按[Enter]后自动插入当前注释首标,但这对于在其中扩展为单行注释的缩写来说是不希望的。没有单独的单行/多行注释字符的语言。
键入缩写字符后,按[Enter]时如何停止获取?
# ========
#
" Eat one character matching the given regex from the input stream, e.g. at
" the end of an abbr expansion. (From :help abbreviations)
func Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc
set pastetoggle=<F12>
iabbr <silent> sep # ========<F12><CR><F12><C-R>=Eatchar('\r')<CR>
此操作将用户的[Enter]按键替换为已生成的按键,并由已生成的按键包围,这些按键可在粘贴之前和之后将其关闭。最后的<C-R>
完成<C-R>=
序列。