Raimondi / delimitMate

Vim plugin, provides insert mode auto-completion for quotes, parens, brackets, etc.
http://www.vim.org/scripts/script.php?script_id=2754
1.98k stars 116 forks source link

Add hotkey for C-style block (curly braces) #268

Open dnezamaev opened 6 years ago

dnezamaev commented 6 years ago

Assume I have text with cursor as | (after $): while ( letter != '$|') now I want to finish while statement and open C-block without typing <S-TAB><S-TAB><CR> or leaving insert mode to get this

while ( letter != '$')
{
  |
}

Now I have simple map in my vimrc to do this inoremap {{ <C-o>o{<CR>}<C-o>O

Works fine, but it always adds new line before open curly brace, so when I want just add C-block on current line this mapping inserts unwanted empty line before C-block.

What I suggest: add to plugin smart C-block expansion that checks if there is some text before cursor or no. And using this information add new line before open brace or no. Also will be nice to have setting to choose style between:

while ( 1 ) {

}

or

while ( 1 ) 
{

}

By the way, thank you for plugin, it is really cool.