问题描述: 在一对大括号之间回车,自动分为3行并调整缩进
代码:
1 2 3 4 5 6 7 8 9 10 11
| autocmd BufWritePre,BufRead *.c :inoremap <Enter> <c-r>=BracketsEnter('}')<CR> autocmd BufWritePre,BufRead *.cpp :inoremap <Enter> <c-r>=BracketsEnter('}')<CR>
function BracketsEnter(char) if getline('.')[col('.')-1] == a:char return "\<Enter>\<Tab>\<Esc>mpa\<Enter>\<Esc>`pa" else return "\<Enter>" endif endf
|