Comments (6)
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.
I've pushed a commit that should implement this. Could you try it out and see if it feels right?
from splitjoin.vim.
Doesn't work with method names ending with either !
or ?
from splitjoin.vim.
Looks great besides that.
from splitjoin.vim.
Ah, of course. I've just pushed a commit that should fix that.
from splitjoin.vim.
LGTM! 😀
from splitjoin.vim.
Related Issues (20)
- YAML should probably honor splitjoin_curly_brace_padding HOT 2
- YAML splitting flow-object with path as value fails to round-trip from joining HOT 3
- Feature request: Add solidity support HOT 1
- Feature request: "black" compatible python line-splitting HOT 3
- Feature request: Add Scala support HOT 3
- Rust: grouped multiline imports do not split correctly HOT 4
- Rust: attributes on grouped imports are not preserved HOT 10
- Adding splitjoins from one langage to another HOT 9
- Unexpected modifications when using `gS` / `gJ` HOT 1
- Python splitting and indentation HOT 2
- Feature request: Splitting LaTeX commands onto newlines HOT 1
- Can't work in visual after changing keymap HOT 2
- Rust: splitting multi-line expression into blocks produces broken code HOT 7
- Go: can't split/join var, const, type declarations inside block (not global scope) HOT 2
- Go: can't split/join var, const declarations with comma-separated one-typed vars, consts HOT 15
- Go: invalid join for var, const, import list HOT 11
- Go: join of struct fields inserts unnecessary spaces HOT 7
- Support for rmardown (rmd) and quarto (qmd) HOT 2
- Go: split of multiline var, const adds brackets in wrong place HOT 2
- vim: gS on dict access dot incorrectly adds space HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from splitjoin.vim.