-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I used to only use spaces and never tabs until a student we had working for us 
explained how to mix them together in a way that makes wrapped lines of code 
line up nicely but still allows different people to use whatever tab width 
they prefer.  The method is explained a little more with an example here:

http://vcl.apache.org/dev/web-code-overview.html#a-word-about-using-tabs-for-code-indentation

I'd copy/paste it here, but a fixed width font is required for the example.

Josh

On Friday, August 23, 2013 8:40:43 PM Aaron Coburn wrote:
> 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+Guideline
> > s
> > 
> > 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
- -- 
- -------------------------------
Josh Thompson
VCL Developer
North Carolina State University

my GPG/PGP key can be found at pgp.mit.edu

All electronic mail messages in connection with State business which
are sent to or received by this account are subject to the NC Public
Records Law and may be disclosed to third parties.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iEYEARECAAYFAlIbcxsACgkQV/LQcNdtPQOLkwCdFA8t9VPPu4HN5AgCRRy5I18m
qLMAniynhuwDwYt2ynk0BNyWaLifthKa
=WJHz
-----END PGP SIGNATURE-----

Reply via email to