2 ms·
That sounds like considerably more work.
by staticassertion 9y ago
That sounds like considerably more work.
- kazinator 9y agoIn Vim (on Unix), type this into the buffer for x in type1 type2 type3 type4 type5 type6 ; do cat <<! impl Into<$x> for ProcessNode { fn into(self) -> $x { $x {some_boilerplate(self)} } } ! done Now do a line-oriented visual select of all the lines from for to done (using V + cursor movements). Then pipe to shell with !sh[Enter]. Poof! The above is replaced with the following: impl Into<type1> for ProcessNode { fn into(self) -> type1 { type1 {some_boilerplate(self)} } } impl Into<type2> for ProcessNode { fn into(self) -> type2 { type2 {some_boilerplate(self)} } } impl Into<type3> for ProcessNode { fn into(self) -> type3 { type3 {some_boilerplate(self)} } } impl Into<type4> for ProcessNode { fn into(self) -> type4 { type4 {some_boilerplate(self)} } } impl Into<type5> for ProcessNode { fn into(self) -> type5 { type5 {some_boilerplate(self)} } } impl Into<type6> for ProcessNode { fn into(self) -> type6 { type6 {some_boilerplate(self)} } } Don't write in some insane boilerplate-driven programming language in the first place. Anyone proliferating this kind of duplication (whether with multi-cursors or shell here docs or any other way) should be flogged.