Sunday, July 28, 2013

Mapping Macro using smartindent

Hello,

I try to speed up writing using mappings.
Smartindent is on, but doesn't work appropriatly.

Example:

Assume the following mapping:

imap { {}<Esc>i<CR><Esc>ko

Typing "{" (Quotes for clarification) results in
"
{
  _
}
" (where "_" is the cursor position) -> Perfect.


But:


--->
line n:  for(int i(0);i<v.size();++i)_
<---

...though typing <Esc>o leads to
---->
line n  : 
for(int i(0);i<v.size();++i)
line n+1:  _
<----

..typing '{' (using the mapping from above) leads to
---->
line n  :  for(int i(0);i<v.size();++i)
line n+1:{
line n+2:  _
line n+3:}
<----

How can I get this?(Appearing the brackets right below the 'f' in the same column)
---->
line n  :  for(int i(0);i<v.size();++i)
line n+1:  {
line n+2:    _
line n+3:  }
<----

Thank you in advance for help.

Best Sven K.

No comments: