Move cursor from surrounds

2017-08-09 16:17:51

What is best way to move cursor from the inside surrounds '"([{ (and other types)?

For example, I'm typing if (condition) { body }. I've typed the condition, then I should go to body.

For me it's very annoying to esc, move cursor, go to insert mode

You could start from this map (and improve it according to your taste):

inoremap /[[({,]\_s*/ea

.. 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.

  • You could start from this map (and improve it according to your taste):

    inoremap /[[({,]\_s*/ea

    .. 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.

    2017-08-09 17:54:51