Pressing Enter inside two braces in insert mode

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Pressing Enter inside two braces in insert mode

Steve-4
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?

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Pressing Enter inside two braces in insert mode

Steven Michalske





> On Jun 30, 2015, at 11:20 AM, Steve <[hidden email]> 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
>
> but is there a plugin available that most people use for situations inside a pair of (),[], {}, <>, etc?
>

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 [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Pressing Enter inside two braces in insert mode

Janusz Bossy-2
In reply to this post by Steve-4
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

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.