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 function!
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?
Sorting text in Vim is easy! Select the text, then press : , type sort , then hit enter! It'll sort the whole document by default, but you can enter a range too.
Mappings to move lines In normal mode or in insert mode, press Alt-j to move the current line down, or press Alt-k to move the current line up.
This could be a bit tricky but here is a tentative way to do it:
g/fun\%[ction]!\= /,/endf\%[unction]/ s/$\n/@@@
'<,'>sort /fun\%[ction]!\=/
%s/@@@/\r/g
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With