JuliaEditorSupport / julia-vim

Vim support for Julia.
http://julialang.org/
Other
747 stars 93 forks source link

feature request: other block form toggles #290

Open ExpandingMan opened 2 years ago

ExpandingMan commented 2 years ago

This is a bit of an ambitious feature request, but I wanted to at least get it documented.

A while ago I asked for a feature in which I could simply push a button and functions would transform back and forth between block form and one line form. Amazingly, the prolific @carlobaldassi added this right away. This feature is wonderful and ever since I use it many times a day. It gets to a problem that writing code always has but very few text editors bother to solve: you never really know how long a line is going to be until you're done writing it.

It would be really great to have this for more block types. For example

if a
    expr
end

# toggles to

a && expr
if !a
    expr
end

# toggles to

a || expr
if a
    expr1
else
    expr2
end

# toggles to

a ? expr1 : expr2
for x in v
    expr
end

# toggles to

foreach(x -> expr, v)
f(y) do x
    expr
end

# toggles to

f(x -> expr, y)

Again, that's a lot and I know this is ambitious to ask for (there's basically no chance I'll ever implement this myself in vimscript, though there's a chance I'll make a separate lua plugin for it one day); but I love the function block feature that already exists so much I thought this deserved an issue.