Skip to content

Instantly share code, notes, and snippets.

@JeffreyWay

JeffreyWay/.vimrc Secret

Created Feb 23, 2016
Embed
What would you like to do?
Auto-sort your PHP 'use' statements by length.
"Sort PHP use statements
"http://stackoverflow.com/questions/11531073/how-do-you-sort-a-range-of-lines-by-length
vmap <Leader>su ! awk '{ print length(), $0 \| "sort -n \| cut -d\\ -f2-" }'<cr>
@JeffreyWay

This comment has been minimized.

Copy link
Owner Author

@JeffreyWay JeffreyWay commented Feb 23, 2016

Visually select the set of 'use' statements, and then press <Leader>su to sort them by length.

@olimorris

This comment has been minimized.

Copy link

@olimorris olimorris commented Feb 23, 2016

You're so good to us. I get particularly annoyed that PHP CS Fixer doesn't do this with their Vim plugin

@cetrix13

This comment has been minimized.

Copy link

@cetrix13 cetrix13 commented Feb 23, 2016

Thank you, for sharing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.