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 endfunfind 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
精彩评论