New answers tagged

3

IMO, it's easier to do simply: inoremap <expr><CR> getline('.') =~# '^\s*//' ? '<C-O>o' : '<CR>' Perhaps, this mapping (with <buffer> modifier, of course) should be added to after/ftplugin/c.vim and not to the global .vimrc


2

The idea of removing :// from 'comments' can be made to work, but instead of leaving Insert mode with <Esc>, use <C-\><C-O> to run a single Normal command (in this case, the : command to run the Ex :set command), returning to Insert mode as soon as that command is completed. Using <C-\><C-O> here instead of <C-O> is ...


Top 50 recent answers are included