Code Monkey home page Code Monkey logo

Comments (6)

AndrewRadev avatar AndrewRadev commented on June 8, 2024

What I use in this case is my switch plugin to transform from [1, 2, 3, 4].map(&:to_s) to [1, 2, 3, 4].map { |x| x.to_s } (relevant docs here). Afterwards, I can rename the x to something else and use splitjoin to split it into multiple lines.

It's slightly inconvenient, since the cursor needs to be on top of the & symbol to make the switch unambiguous. I guess it wouldn't be hard to implement this as a shorthand in splitjoin, and it would be more reliable. I'll see what I can do about it.

As for the name of the variable, you're right, there's no way to guess it. Singularizing a variable name seems like a nice idea for a default, but might be kind of hard to detect reliably. I'd just use an "x" or something and leave it to the user to rename. Even with that, I still think this kind of transformation would provide value.

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on June 8, 2024

I've pushed a commit that should implement this. Could you try it out and see if it feels right?

from splitjoin.vim.

glittershark avatar glittershark commented on June 8, 2024

Doesn't work with method names ending with either ! or ?

from splitjoin.vim.

glittershark avatar glittershark commented on June 8, 2024

Looks great besides that.

from splitjoin.vim.

AndrewRadev avatar AndrewRadev commented on June 8, 2024

Ah, of course. I've just pushed a commit that should fix that.

from splitjoin.vim.

glittershark avatar glittershark commented on June 8, 2024

LGTM! 😀

from splitjoin.vim.

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.