Shougo / neosnippet.vim

neo-snippet plugin
Other
1.12k stars 108 forks source link

Ability to insert a number of spaces equal to the length of another placeholder value #329

Closed taladar closed 7 years ago

taladar commented 8 years ago

This would be useful in many cases to automatically align continuation lines, e.g. for parameter lists that need to be aligned to the starting parentheses column which depends on the length of the name of the function.

Shougo commented 8 years ago

Please upload the examples. I cannot imagine your new feature...

taladar commented 8 years ago

I was thinking of snippets with content like this (Haskell)

data ${1} =
  $1 { ${2} :: ${3}
     , ${4} :: ${0}
     } deriving (Eq, Ord)

Here it would be nice to have the ability to align the third, fourth,... line's comma and closing curly brace with the opening curly brace of the second line. The auto-indentation does not do this so it would be nice if we could do it manually in the snippet by placing whitespace the same length as $1 in those lines.

A similar example in e.g. C might be

void ${1}( ${2}
         , ${0}
         )
{
}

where we want to align the second and third lines with the opening parentheses on the first though I think the need might be more common in languages with semantic whitespace like Haskell where the auto-indenter is probably more conservative in re-indenting things.

Shougo commented 8 years ago

I get it. But I think it is not snippet plugin's work. And I think it is hard to implement.