Skip to content

Instantly share code, notes, and snippets.

@rleger

rleger/.vimrc

Last active Mar 29, 2016
Embed
What would you like to do?
Vim Sort Php Use
// Sort PHP use imports by length
// You don't have to select the use imports, hitting <leader>su anywhere in your file
// will sort the imports and put your cursor back where you left off.
//
// Replace ^M by hitting <C-v><C-m> in insert mode
function! SortPhpUseByLength()
exec 'normal mrgg/^use\s^Mma/^class\s^M/^use\s^MNmb:nohlsearch^M:''a,''b! awk ''{ print length(), $0 | "sort -n | cut -d\\ -f2-" }''^M''r'
endfunction
nmap <leader>su :call SortPhpUseByLength()<cr>
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.