Alignment that contains comment lines that has ending "{"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Alignment that contains comment lines that has ending "{"

karl cai-2
The version I used is 8.9.586.
I noticed that vim alignment for c program is kind of strange. For example, in the following example, when line "//if(2) {" is in front of line "if(1) {", the alignment is fine (used gg=G to align the whole file). But if I switch the order of these two lines, the last "}" doesn't align correctly. Is this a known problem of vim? Any work around?

Similar question is for the match command "%": It seems the % command take the ending "{" in a comment line into account as well. In the following example, the first "{" can't find any matching "}". Is there a way to solve this problem? Thanks.
--Karl

#include <stdio.h>

int main()
{
    //if (2) {
    if (1) {
        printf("1\n");
    }
}

=====================
#include <stdio.h>

int main()
{
    if (1) {
        //if (2) {
        printf("1\n");
    }
    } <<<< not aligned well.

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