Andy, this is great. A consistent coding style makes things much easier for 
everyone.

I agree with pretty much everything listed on this page, except that I think 
the best way to keep indentation consistent across editors is to expand tabs 
with spaces.  That said, I don't actually feel very strongly about this, so I 
can start using tabs (I'm certainly guilty of adding spaces to the code).

If you use vim (I do exclusively), there are two ways to set these controls: 
either per-file or globally.

I would think it is best to make these changes globally (in a .vimrc file) 
rather than adding vim modeline commands to each file in the distribution.

In your ~/.vimrc file, add some lines such as:

if has("autocmd")
  autocmd FileType perl setl ts=4 sw=4 noexpandtab
endif " has("autocmd")

If, however, you prefer to add the modeline commands to each file, they would 
look like this:

#!/bin/perl -w

# vim: ts=4 sw=4 noexpandtab

The only item I would add to the page is something about including a space 
between all operators.

That is, this is not ideal:

  my $x = $y+$z;

and this is better:

  my $x = $y + $z;


-Aaron


On Aug 23, 2013, at 3:46 PM, Andy Kurth <[email protected]> wrote:

> I started a wiki page to describe how all backend Perl code should be styled:
> https://cwiki.apache.org/confluence/display/VCL/Perl+Code+Style+Guidelines
> 
> It mostly describes how the vast majority of the existing code is
> styled and formatted, though there are several places where things
> need to be cleaned up.  If you're working on any Perl code, please
> look over this document and feel free to add to it or reply with
> anything you don't agree with.
> 
> Inconsistent indentation drives me nuts and was the main reason I felt
> the urge to write this up.  I use a GUI editor which is configured to
> autoindent with tabs but occasionally I'll edit some lines using vi on
> a server and know it's easy to munge existing tabs with spaces.  If
> there are any vi/vim experts out there, please share your
> autoindent/tabstop settings.
> 
> Thanks,
> Andy

Reply via email to