开发者

VIM: Sort by Function name

I have a lot of functions in my menu.vim file.

Would it be possible to select them (by me) and sort them by function name?

p.e.

find lines from fun! or functio开发者_如何学Gon!

to line endfun

find name of function and sort the whole block based on the name of function (from a-z)

Sometimes I have one line of comment above the function name.

Can it be taken with it?


This could be a bit tricky but here is a tentative way to do it:

  • choose a substitution pattern that is not in your source file, like @@@
  • g/fun\%[ction]!\= /,/endf\%[unction]/ s/$\n/@@@
  • Then, select all one-liners and use '<,'>sort /fun\%[ction]!\=/
  • %s/@@@/\r/g
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜