Create a gist now

Instantly share code, notes, and snippets.

@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.

Show comment
Hide comment
@JeffreyWay

JeffreyWay Feb 23, 2016

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

Owner

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.

Show comment
Hide comment
@olimorris

olimorris 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

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.

Show comment
Hide comment
@cetrix13

cetrix13 Feb 23, 2016

Thank you, for sharing it.

Thank you, for sharing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment