Enter empty line between brackets/parens

1 Point

Zenith-One Zenith-One

8 years ago

Coupled with the delimitMate plugin (https://github.com/Raimondi/delimitMate), these bindings allow you to enter an empty line in between opening/closing brackets or parentheses (or wherever really, that's just how I use it), all without leaving insert mode (manually, anyway). So, for example:

function foo(){|} The | is the cursor

results in:

function foo(){

|

}

(again, the | is the cursor, and you're in insert mode)

The second snippet does the same thing, except it adds a semicolon at the end of the current line first.

" <C-c> enters an empty line inside brackets/parens
" Best used with Raimondi/delimitMate
" Full disclosure: I yanked this first one 
" from somewhere, but I can't remember where.
inoremap <C-c> <CR><Esc>O

" As above, but adds a semicolon at the end of the current line first.
inoremap <leader><C-c> <Esc>mSA;<Esc>`Sa<CR><Esc>O

Romain Lafourcade

Romain Lafourcade 8 years ago

The first feature is already in delimitMate: :help delimitMateExpansion.