5 ms·
Vim-c-cr, a super simple plugin to give ctrl+enter a little magic
- daturkel 13y agoThis is potentially very nice for CSS. Thanks for sharing!
- johncoltrane 13y agoNote that <C-CR> only works in GUI Vim because it is virtually indistinguishable from <CR> in (most?) terminal emulators. They actually send different signals but Vim doesn't care. I've had many slightly dumber variations of that mapping in my ~/.vimrc for a while, using <leader><CR> instead of <C-CR> for the reason outlined above. Edit I borrowed you Closer() function and modified it to make it work simply on <CR>, based on my previous mapping: " my previous mapping inoremap <leader><CR> <CR><C-o>==<C-o>O " your revised function function! Closer() let prevchar = getline(".")[col(".")-2] if prevchar ==# "{" return "\<CR>}\<C-o>==\<C-o>O" elseif prevchar ==# "[" return "\<CR>]\<C-o>==\<C-o>O" elseif prevchar ==# "(" return "\<CR>)\<C-o>==\<C-o>O" else return "\<CR>" endif endfunction " your revised mapping inoremap <expr> <CR> Closer()