You could start from this map (and improve it according to your taste):
inoremap <C-x><C-x> <Esc>/[[({,]\_s*/e<CR>a
.. which maps Ctrl-x Ctrl-x
in insert mode to jump after a set of characters (open brackets, I added comma since it could be useful also to jump over function arguments), skipping also any white spaces or newlines that follow. So, if the text is written, just hit Ctrl-x Ctrl-x
to move to the 'next' position, until the cursor is where you want it. How you then change the code that follows is your decision.
if
snippet that has placeholders forcondition
andbody
, placeholders that can be edited and jumped from one to the another. Other than that, in Vim there are many ways to quickly "move cursor" with precision to a desired location.tab
,CTRL-J
or whatever the plugin/placeholder system uses and you'll be doing all those tasks at once:<esc>/{<cr>o
. The downside is that you need abbreviations or snippets for all the control statements you could use. Fortunately, C control statements are well spread. I even have a for-range loop for C++ in lh-cpp. If some part of the body has already been typed, well, you'll need to define a mapping to do what you wish.condition
you can do<Esc>f{a
which isn't that bad... Now if you really want to cut some keystrokes the plugin solution seems pretty good.<C-o>
which let you execute a normal command before returning in insert mode:<C-o>fb