Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Vim:

    set expandtab

    And your troubles are over :)

    ... until you have to edit a friggin' Makefile :(

    (expandtab converts tabs to their equivalent spaces. There are many similar commands to get fine-grained control over this)

    Of course, if you just want to show unwanted whitespace, we have plenty of builtin ways of doing that [wikia.com].

    • You mean vim isn't smart enough to know you need leading tabs in Makefiles? Hmm, too bad.

      • No, Ovid just isn’t smart enough yet to tell it. :-)

        From my .vimrc:

        autocmd FileType python setlocal expandtab

      • Oh, and the make filetype plugin could easily set this automatically. I don’t know why it doesn’t, but it doesn’t bother me that it does not, either.

      • It's configurable on a "per filetype" basis. I just don't edit makesfiles often enough to care and I set it manually then.

    • The real equivalent to what Michael is doing is called :set list, which will render tabs as ^I. In vim but not vi you can also use the listchars variable to control how tabs are rendered, as well as various other invisible things like end of line, trailing whitespace, line cut-off at screen edges, etc.

  • Tab users like to tout that it allows you to use whatever indentation level you like when in reality you just wind up with mixed up tabs and spaces.

    I’ve been programming with tabs for indentation and spaces for alignment for the better part of a decade.

    I’ve never had a single problem keeping things straight in my own code.

    • I've never had a single problem keeping things straight in my own code.

      Its your code and your style, of course it makes sense to you! You could write in rot13'd Swahili and it would still make sense, but only to you.

      Here is the best advice I can give about writing maintainable code: It's not about you. It's about everyone else. Each personal style quirk that others have to puzzle out or adjust to or in any way hampers and frustrates their ability to quickly skim and patch your code loses you patches. T

      • Schwern
        , I think you underestimate the productivity gains
        ; your quirky style is my well-tuned machine!

      • You could write in rot13’d Swahili and it would still make sense

        Oh please. Your argument might hold water if you weren’t talking to someone who is about 17× more obsessed with clarity than the average programmer – and has gotten the compliments to prove that it makes sense to others. (I hate boasting, but for the sake of this argument I need to point out the evidence that it’s not just in my head.)

        It’s not about you. It’s about everyone else.

        When in Rome, I do as t

        • Oh please. Your argument might hold water if you weren’t talking to someone who is about 17× more obsessed with clarity than the average programmer – and has gotten the compliments to prove that it makes sense to others. (I hate boasting, but for the sake of this argument I need to point out the evidence that it’s not just in my head.)

          Don't get so excited, I do silly things too.

          Unfortunately, this is an ad hominem argument essentially sayi

          • If N projects each have their own style each contributor must learn N styles.

            Ah, the Python school of thought. I like Perl better.

            • [Hmm, is invoking Python the Perl variation on Godwin's Law?]

              Although the Perl Slogan is There's More Than One Way to Do It, I hesitate
              to make 10 ways to do something. :-)
                              --Larry Wall in

              There is merit in the Python view on style. Like anything else, the key is knowing when to apply a rule and when not to. You don't want to over do it and pave the community flat. You don't want to under do it and wind up with style Balkanization. I think it's perfe

    • I'm 100% with Schwern on this one. Tabs for indentation are just evil. Sure it works OK for you because you have your tools set up a certain way. But when you collaborate with others their tools will be set up differently and what they see will be different to what you see. For example I picked one of your CPAN modules at random and scrolled down looking for messed up indents. Sure enough in XML/Atom/SimpleFeed.pm [cpan.org] starting line 334 you have a group of lines that are indented with space rather than tabs

      • Figures. From looking at what part of the file it happened in, I know exactly what went wrong, too. Vim and me, we let each other down, there… :-(

        I’ve added set list to my .vimrc to ensure it won’t happen again.

        (The apparently-empty lines that this exercise revealed further down the file (in the POD section, l.427 ff.) bug me even more.)

  • So you expected the vim users to flog you with comments. I'm a vim user, but here's for something different:

    With *Padre*, you can configure your favourite indentation setting, then check the little box that says "automatic indentation finding" or somesuch and it'll use your own style for new files, but it will automatically adapt to the indentation style of existing files as you open them! It also honours the vim and emacs style magic comments that are used here or there for setting the indentation style.

    It

    • Ok, that's damn hot. Now I will give Padre another look.

      • The really strange thing is that it's such a basic convenience feature that could and should be implemented anywhere.

        The current implementation of the indentation finding in Padre is actually pretty horrible. It's in the Text::FindIndent module on CPAN. (I hacked it up so I can bash it, too.) The one thing that breaks it occasionally is POD. If you have a lot of POD with verbatim blocks in it (where most people use spaces regardless of how they indent their code), they aren't ignored. That would be a rather