Giter Club home page Giter Club logo

Comments (3)

tmhedberg avatar tmhedberg commented on August 18, 2024

It would be fairly easy to add support for this case, but to be honest, I'd argue that it might be better just to fix your indentation. :)

The de facto standard Python style guide, PEP 8, states:

Block comments generally apply to some (or all) code that follows them, and are indented to the same level as that code.

Making comments flush with the left margin when they are nested inside of indented definitions is unusual.

Everyone has their own style, of course, and we can add special cases to SimpylFold to handle all sorts of variations on the standard format. But that's really an exercise in futility; there will always be more subtle variations that people can come up with. Without writing a full-fledged Python parser in VimScript, we'll never be able to handle them all. I think it's best for this plugin to expect PEP 8-formatted code, and to only add special cases for deviations from that style when the deviations are very common, or when the failure mode is particularly problematic (like sending Vim into an infinite loop).

However, if you simply can't live with this restriction, I'll see what I can do. And patches are always welcome, of course.

from simpylfold.

tmhedberg avatar tmhedberg commented on August 18, 2024

Closing this for now, but you can reopen it if you feel like the conversation on this topic needs to be continued.

from simpylfold.

mgedmin avatar mgedmin commented on August 18, 2024

I have a habit of temporarily commenting out bits of code like this while I'm debugging stuff:

def somefunc(...):
    do_this()
##  do_that()
    do_this_again()

I like it because it doesn't change the indentation of the commented-out code, and because it's easy to comment/uncomment in vim with 0R##<esc> or 0R<space><space><esc>. (The hash-mark is doubled to make it explicit that this is a bit of temporarily-commented-out code, and not a real comment.)

I never commit commented-out code, so I don't consider it a PEP-8 violation ;)

Anyway, if I switch to SimpylFold instead of my hacky foldexpr, I'll have to see if I can create a patch for this.

from simpylfold.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.