C++11 Lambda indentation in vim 7.4

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

C++11 Lambda indentation in vim 7.4

Klaus Rudolph
C++ Lambda Expressions are now not longer an error in syntax highlighting and indentation since vim 7.4. But inside a lambda expression the indentation did not work as I expect.

Auto indent (gg=G) gives the following result:

    auto  x1=GenFunktor(
            []()
            {  
            a+=2;
            {
            int x;
            x++;
            }
            }  
            );

What I expect:

    auto  x1=GenFunktor
           (
            []()
              {  
                  a+=2;
                  {
                      int x;
                      x++;
                  }
              }  
            );

"simply" the normal indentation rules should also work inside the lambda expression. Is there a configuration setting to enable that?

Regards
   Klaus
 

--
--
You received this message from the "vim_use" 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_use" 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
|  
Report Content as Inappropriate

Re: C++11 Lambda indentation in vim 7.4

Jacky Alciné

Why not funnel the buffer to an external formatting tool and replace the buffer's content with that?

Jacky Alciné
Sent from my Nexus 7

On Mar 26, 2014 10:12 AM, "Klaus Rudolph" <[hidden email]> wrote:
C++ Lambda Expressions are now not longer an error in syntax highlighting and indentation since vim 7.4. But inside a lambda expression the indentation did not work as I expect.

Auto indent (gg=G) gives the following result:

    auto  x1=GenFunktor(
            []()
            {
            a+=2;
            {
            int x;
            x++;
            }
            }
            );

What I expect:

    auto  x1=GenFunktor
           (
            []()
              {
                  a+=2;
                  {
                      int x;
                      x++;
                  }
              }
            );

"simply" the normal indentation rules should also work inside the lambda expression. Is there a configuration setting to enable that?

Regards
   Klaus


--
--
You received this message from the "vim_use" 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_use" 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_use" 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_use" 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
|  
Report Content as Inappropriate

Re: C++11 Lambda indentation in vim 7.4

Christian Brabandt
In reply to this post by Klaus Rudolph
On Mi, 26 Mär 2014, Klaus Rudolph wrote:

> C++ Lambda Expressions are now not longer an error in syntax highlighting and indentation since vim 7.4. But inside a lambda expression the indentation did not work as I expect.
>
> Auto indent (gg=G) gives the following result:
>
>     auto  x1=GenFunktor(
>             []()
>             {  
>             a+=2;
>             {
>             int x;
>             x++;
>             }
>             }  
>             );
>
> What I expect:
>
>     auto  x1=GenFunktor
>            (
>             []()
>               {  
>                   a+=2;
>                   {
>                       int x;
>                       x++;
>                   }
>               }  
>             );
>
> "simply" the normal indentation rules should also work inside the lambda expression. Is there a configuration setting to enable that?

I believe this needs a patch to vim for the builtin c indenting.
Redirecting to vim_dev.

Alternatively, there might exist some custom indenting scripts using
indentexpr() of Vim. Look at the scripts section at vim.org or github

Best,
Christian
--
Packungsaufschriften US-amerikanischer Produkte:
Auf SAINSBURY'S Erdnüssen:
Warnung: Enthält Nüsse.

--
--
You received this message from the "vim_use" 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_use" 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
|  
Report Content as Inappropriate

Re: C++11 Lambda indentation in vim 7.4

Yongwei Wu
In reply to this post by Klaus Rudolph
Did you try clang-format? C++ is so complex a language that only a real C++ parser can deal things correctly. Clang-format is also highly configurable, with easy integration with Vim.

On 26 March 2014 22:12, Klaus Rudolph <[hidden email]> wrote:
C++ Lambda Expressions are now not longer an error in syntax highlighting and indentation since vim 7.4. But inside a lambda expression the indentation did not work as I expect.

Auto indent (gg=G) gives the following result:

    auto  x1=GenFunktor(
            []()
            {
            a+=2;
            {
            int x;
            x++;
            }
            }
            );

What I expect:

    auto  x1=GenFunktor
           (
            []()
              {
                  a+=2;
                  {
                      int x;
                      x++;
                  }
              }
            );

"simply" the normal indentation rules should also work inside the lambda expression. Is there a configuration setting to enable that?

Regards
   Klaus


--
--
You received this message from the "vim_use" 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_use" 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.



--
Wu Yongwei
URL: http://wyw.dcweb.cn/

--
--
You received this message from the "vim_use" 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_use" 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
|  
Report Content as Inappropriate

Re: C++11 Lambda indentation in vim 7.4

mattn
In reply to this post by Christian Brabandt
On Thursday, July 27, 2017 at 4:41:01 PM UTC+9, Ivan Smirnov wrote:

> On Wednesday, 26 March 2014 21:51:43 UTC, Christian Brabandt  wrote:
> > On Mi, 26 Mär 2014, Klaus Rudolph wrote:
> >
> > > C++ Lambda Expressions are now not longer an error in syntax highlighting and indentation since vim 7.4. But inside a lambda expression the indentation did not work as I expect.
> > >
> > > Auto indent (gg=G) gives the following result:
> > >
> > >     auto  x1=GenFunktor(
> > >             []()
> > >             {  
> > >             a+=2;
> > >             {
> > >             int x;
> > >             x++;
> > >             }
> > >             }  
> > >             );
> > >
> > > What I expect:
> > >
> > >     auto  x1=GenFunktor
> > >            (
> > >             []()
> > >               {  
> > >                   a+=2;
> > >                   {
> > >                       int x;
> > >                       x++;
> > >                   }
> > >               }  
> > >             );
> > >
> > > "simply" the normal indentation rules should also work inside the lambda expression. Is there a configuration setting to enable that?
> >
> > I believe this needs a patch to vim for the builtin c indenting.
> > Redirecting to vim_dev.
> >
> > Alternatively, there might exist some custom indenting scripts using
> > indentexpr() of Vim. Look at the scripts section at vim.org or github
> >
> > Best,
> > Christian
> > --
> > Packungsaufschriften US-amerikanischer Produkte:
> > Auf SAINSBURY'S Erdnüssen:
> > Warnung: Enthält Nüsse.
>
> Wonder if anyone has a solution to this yet?
Could you please try this?

https://gist.github.com/b6cc675eac4c67c923b1d952307947f7

--
--
You received this message from the "vim_use" 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_use" 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
|  
Report Content as Inappropriate

Re: C++11 Lambda indentation in vim 7.4

mattn
In reply to this post by Christian Brabandt
Sorry, this instead.

https://gist.github.com/b6cc675eac4c67c923b1d952307947f7

--
--
You received this message from the "vim_use" 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_use" 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.
Loading...