Re: Enforcing coding standards using vim

2012-10-22 Thread Reid Thompson
On Mon, 2012-10-22 at 07:55 -0700, Ben Fritz wrote:
> > 
> > Thanks John. It should be good to follow your work. Perhaps looking at
> > 
> > your code would give me some clue as to what I could do for C/C++.
> > 
> > Yesterday I also found a free package called Artistic Style
> > 
> > (astyle.sourceforge.net) which does a decent job as a code-formatter.
> > 
> > However the utility of something like vim_tidy_code would still
> > 
> > remain.
> > 
> > 
> 
> I was going to say that Artistic Style looked like something that would be 
> good to use in your 'equalprg' or 'formatprg' option, but then I found that 
> Artistic Style does not yet support getting text from stdin or writing to 
> stdout:
> 
> http://sourceforge.net/tracker/index.php?func=detail&aid=3017627&group_id=2319&atid=102319
> 
> So you'd probably need to wrap it in a function called from formatexpr, to 
> write text out to a temp file and read it back in when done. Then you can use 
> gq to format stuff (gggqG to format the entire buffer). I think you can also 
> get automatic formatting with the 'formatoptions' option this way.
> 

https://www.google.com/search?q=code+beautifier+with+vim&oq=code+beautifier+with+vim&sugexp=chrome,mod=0&sourceid=chrome&ie=UTF-8#hl=en&sclient=psy-ab&q=code+beautifier+&oq=code+beautifier+&gs_l=serp.3..0l4.18245.18245.0.18432.1.1.0.0.0.0.77.77.1.1.0.les%3B..0.0...1c.1.dIb14cMkVbc&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&fp=6bfb452b84afdba5&bpcl=35466521&biw=1832&bih=897

a very quick glance shows that indent reads stdin writes stdout as does 
uncrustify  -- I
would imagine that others do also

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


Re: Enforcing coding standards using vim

2012-10-22 Thread Ben Fritz
On Sunday, October 21, 2012 9:54:06 AM UTC-5, Arindam Mukherjee wrote:
> On Sun, Oct 21, 2012 at 5:59 PM, John Evans  wrote:
> 
> > On Saturday, October 20, 2012 7:05:41 PM UTC+1, Arindam Mukherjee wrote:
> 
> >> Hi,
> 
> >>
> 
> >>
> 
> >>
> 
> >> Is there a way to enforce certain coding standards for C or C++ code,
> 
> >>
> 
> >> beyond indentation (for which I found google.vim). Stuff like:
> 
> >>
> 
> >>
> 
> >>
> 
> >> 1. Always put a single space after an if, while, for, etc and the
> 
> >>
> 
> >> following left-parenthesis.
> 
> >>
> 
> >> 2. Always put spaces around operators.
> 
> >>
> 
> >>
> 
> >>
> 
> >> There could be more.
> 
> >>
> 
> >>
> 
> >>
> 
> >> I tried writing a set of search replace strings and mapping them to a
> 
> >>
> 
> >> single key-sequence. However, I'm having difficulty distinguishing
> 
> >>
> 
> >> between content that's inside a double-quoted string and outside it.
> 
> >>
> 
> >>
> 
> >>
> 
> >> Thanks,
> 
> >>
> 
> >> Arindam
> 
> >
> 
> >
> 
> > Wierdly I am just in the process of starting a script that does this sort 
> > of thing.
> 
> >
> 
> > https://github.com/evanswebdesign/vim_tidy_code
> 
> >
> 
> > It is in the very very early stages and at the minute I'm just 
> > concentrating on PHP. I'm basically going through all my code in all my 
> > projects to find things that are wrong that I can use the script to correct.
> 
> >
> 
> > I've only been using vim for a year of so and git even less than that so 
> > I'm still learning various things.
> 
> >
> 
> > I've not posted it in to the scripts site as yet because it's in such an 
> > infant stage.
> 
> > John
> 
> >
> 
> 
> 
> Thanks John. It should be good to follow your work. Perhaps looking at
> 
> your code would give me some clue as to what I could do for C/C++.
> 
> Yesterday I also found a free package called Artistic Style
> 
> (astyle.sourceforge.net) which does a decent job as a code-formatter.
> 
> However the utility of something like vim_tidy_code would still
> 
> remain.
> 
> 

I was going to say that Artistic Style looked like something that would be good 
to use in your 'equalprg' or 'formatprg' option, but then I found that Artistic 
Style does not yet support getting text from stdin or writing to stdout:

http://sourceforge.net/tracker/index.php?func=detail&aid=3017627&group_id=2319&atid=102319

So you'd probably need to wrap it in a function called from formatexpr, to 
write text out to a temp file and read it back in when done. Then you can use 
gq to format stuff (gggqG to format the entire buffer). I think you can also 
get automatic formatting with the 'formatoptions' option this way.

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


Re: Enforcing coding standards using vim

2012-10-21 Thread Arindam Mukherjee
On Sun, Oct 21, 2012 at 5:59 PM, John Evans  wrote:
> On Saturday, October 20, 2012 7:05:41 PM UTC+1, Arindam Mukherjee wrote:
>> Hi,
>>
>>
>>
>> Is there a way to enforce certain coding standards for C or C++ code,
>>
>> beyond indentation (for which I found google.vim). Stuff like:
>>
>>
>>
>> 1. Always put a single space after an if, while, for, etc and the
>>
>> following left-parenthesis.
>>
>> 2. Always put spaces around operators.
>>
>>
>>
>> There could be more.
>>
>>
>>
>> I tried writing a set of search replace strings and mapping them to a
>>
>> single key-sequence. However, I'm having difficulty distinguishing
>>
>> between content that's inside a double-quoted string and outside it.
>>
>>
>>
>> Thanks,
>>
>> Arindam
>
>
> Wierdly I am just in the process of starting a script that does this sort of 
> thing.
>
> https://github.com/evanswebdesign/vim_tidy_code
>
> It is in the very very early stages and at the minute I'm just concentrating 
> on PHP. I'm basically going through all my code in all my projects to find 
> things that are wrong that I can use the script to correct.
>
> I've only been using vim for a year of so and git even less than that so I'm 
> still learning various things.
>
> I've not posted it in to the scripts site as yet because it's in such an 
> infant stage.
> John
>

Thanks John. It should be good to follow your work. Perhaps looking at
your code would give me some clue as to what I could do for C/C++.
Yesterday I also found a free package called Artistic Style
(astyle.sourceforge.net) which does a decent job as a code-formatter.
However the utility of something like vim_tidy_code would still
remain.

Arindam

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


Re: Enforcing coding standards using vim

2012-10-21 Thread John Evans
On Saturday, October 20, 2012 7:05:41 PM UTC+1, Arindam Mukherjee wrote:
> Hi,
> 
> 
> 
> Is there a way to enforce certain coding standards for C or C++ code,
> 
> beyond indentation (for which I found google.vim). Stuff like:
> 
> 
> 
> 1. Always put a single space after an if, while, for, etc and the
> 
> following left-parenthesis.
> 
> 2. Always put spaces around operators.
> 
> 
> 
> There could be more.
> 
> 
> 
> I tried writing a set of search replace strings and mapping them to a
> 
> single key-sequence. However, I'm having difficulty distinguishing
> 
> between content that's inside a double-quoted string and outside it.
> 
> 
> 
> Thanks,
> 
> Arindam


Wierdly I am just in the process of starting a script that does this sort of 
thing.

https://github.com/evanswebdesign/vim_tidy_code

It is in the very very early stages and at the minute I'm just concentrating on 
PHP. I'm basically going through all my code in all my projects to find things 
that are wrong that I can use the script to correct.

I've only been using vim for a year of so and git even less than that so I'm 
still learning various things.

I've not posted it in to the scripts site as yet because it's in such an infant 
stage.
John 

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


Re: Enforcing coding standards using vim

2012-10-20 Thread lith
> Is there a way to enforce certain coding standards for C or C++ code,
> beyond indentation (for which I found google.vim). Stuff like:

If there is a (external) style checker available that fits your needs, you 
could use it as compiler (or via plugins like syntastic or checksyntax) to 
identify lines that don't meet your requirements.

Alternatively, you could define a after/syntax/c/style.vim file and define 
syntax groups that match & highlight frequent mistakes. But I don't think 
that's a good idea in your case though.

Regards

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


Enforcing coding standards using vim

2012-10-20 Thread Arindam Mukherjee
Hi,

Is there a way to enforce certain coding standards for C or C++ code,
beyond indentation (for which I found google.vim). Stuff like:

1. Always put a single space after an if, while, for, etc and the
following left-parenthesis.
2. Always put spaces around operators.

There could be more.

I tried writing a set of search replace strings and mapping them to a
single key-sequence. However, I'm having difficulty distinguishing
between content that's inside a double-quoted string and outside it.

Thanks,
Arindam

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