0

There is a really helpful article on Vim's wiki here that is nearly exactly what I want to do, I think I'm just missing something small.

I would like to take this line:

<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>

and make it into:

<%= simple_form_for(resource, 
                    as: resource_name, 
                    url: session_path(resource_name)
                    ) do |f| %>

However when I run: /[(,)] :s//\r&/g

I get:

<%= simple_form_for
(resource
, as: resource_name
, url: session_path
(resource_name
)
) do |f| %>

I need the linebreaks to happen AFTER the commmas and I'm unsure the regex to provide to make that happen. Thoughts?

Anthony
  • 15,435
  • 4
  • 39
  • 69

2 Answers2

1

Here is how you would replace every comma by a comma followed by a newline.

:s/,/&\r/g

If you also want to separate every pair of two )) by a newline, you can do this.

%s/))/)\r)/g
merlin2011
  • 71,677
  • 44
  • 195
  • 329
0

Thanks @FDinoff ! I figured it out, it was simply rearranging my search & replace with:

:s//&\r/g

Anthony
  • 15,435
  • 4
  • 39
  • 69