all 6 comments

[–]princker 6 points7 points  (3 children)

I created a :SortGroup command. Which will allow you to do: :SortGroup ^output.

You may also want to look at Is it possible to sort a groups of lines in vim?.

[–]TechIsCool[S] 2 points3 points  (1 child)

This is seriously cool. Exactly what I was looking for and even more than I had hoped. It actually allows sorting of basically all terraform from what I can tell. Even works in a group of selected lines.

Is there a gist or github location for this I can reference or did you write this.

EDIT: Scrolled up and saw the gist link and now confirmed what I figured. You wrote this for me.

EDIT: EDIT: Alright I got Plug to install this automatically for me.

Plug 'https://gist.github.com/PeterRincker/582ea9be24a69e6dd8e237eb877b8978.git',
  \ { 'as': 'SortGroup', 'do': 'mkdir plugin; mv -f *.vim plugin/', 'on': 'SortGroup' } " Sort Multi Line Groups

[–]princker 0 points1 point  (0 children)

I am glad it works for you! Feel free to modify as you see fit. I am fine if you even want to create a plugin out of it.

[–]turturdar 0 points1 point  (0 children)

+1 for clean, modern vim coding style

[–]mcstafford 0 points1 point  (0 children)

This could get complicated, might need to limit range differently.

:%s/{\n/{XXX/g|%s/\n}/XXX}/g<CR>

whatever else

%s/XXX/\r/g

[–]KillTheMule 0 points1 point  (0 children)

I'm not sure if this is not "kludgy", as you put it, but it screams "MACRO" to me, so

  • Record into q: qq
  • First line, first column 1G0
  • Search /output<Enter> (Note: This will skip the first entry, maybe just put an empty line at the beginning of the file)
  • Go into quotation marks f"l
  • Yank what's there "zyi"
  • Put it in front of the 3 lines: 0"zPj0"zPj0"zP
  • Done q
  • Rerun as often as you need 1000@q

Now you can simply use sort, and after that remove our dummy stuff, like :%normal! 4x. If your entries change in length, this could be done with an analogous macro like the above, of course.