Pressing Enter inside two braces in insert mode

12 views
Skip to first unread message

Steve

unread,
Jun 30, 2015, 3:58:39 PM6/30/15
to vim...@googlegroups.com
If I have typed this (‘|’ is cursor position):

class Something {|}

when I press return, I would like to see this

class Something {
|
}

I know I can do this with the key sequence <Enter><Esc>O

but is there a plugin available that most people use for situations inside a pair of (),[], {}, <>, etc?

Steven Michalske

unread,
Jun 30, 2015, 4:26:30 PM6/30/15
to vim...@googlegroups.com
I'm sure that there are vim plugins to do this. Search the vim.org page for a vim script for automatic formatting that language you are programming in.

This vim list has a smaller audience as it primarily is related to the macvim port of vim.

Asking this question on the main vim list will get you a larger audience. After searching the vim scripts.




> --
> --
> You received this message from the "vim_mac" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_mac" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Janusz Bossy

unread,
Jul 1, 2015, 9:07:12 PM7/1/15
to vim...@googlegroups.com
On Tue, Jun 30, 2015, at 20:20, Steve wrote:
> If I have typed this (‘|’ is cursor position):
>
> class Something {|}
>
> when I press return, I would like to see this
>
> class Something {
> |
> }
>
> I know I can do this with the key sequence <Enter><Esc>O

I've actually done this without using any plugins using a simple
mapping:

inoremap {<cr> {<cr>}<esc>O

The bonus is that you don't have to even type the closing } :)

--
Janusz Bossy
Reply all
Reply to author
Forward
0 new messages