Split line with dots

http://www.vimgolf.com/challenges/57343555fd77ad227900df4a

Best vim score: 15

Split line with dots

Start file:

class VimGolf
  def split_me
    MyModel.first_method.second_method(arg).third_method(arg.method_one.method_two)
  end
end

End file:

class VimGolf
  def split_me
    MyModel
      .first_method
      .second_method(arg)
      .third_method(arg.method_one.method_two)
  end
end

this one is fun – and trickier than it looks.

Naive solution is 19 keys
2jxs\.<ret><a-space><a-space>i<ret><esc><gt>hy2p,q

who can do better? :smiley:
edit:
17: %s\.<ret><a-space><a-space>i<ret><esc><gt>hy2p,q

edit: actually it was simpler than it looks :sweat_smile:
I’v got 15.
Qf.;i<ret><space><space><esc><gt>Q2q,q

I also got 15:
f)Ls\.<ret>i<ret><space><space><esc><gt>,q
or
%s\.<ret><a-space><a-space>i<ret><space><space><esc><gt>,q

A bunch of 16s with a different method.

@TeddyDD Want to make a PR to the golf repo?

1 Like

I opened a PR but I think your solution (%s...) is more idiomatic, so feel free to open PR, I’ll close mine then :slight_smile:

I think your is fine. The first part of the %s was stolen from you anyway :slight_smile:

I submitted version with macro, but your version is better:
%s\.<ret><a-space><a-space>i<ret><space><space><esc><gt>,q

edit: I added your version, I hope you don’t mind