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