Last active
March 29, 2016 21:01
-
-
Save rleger/3e26c0ed78b64f08d1540b2f0d148777 to your computer and use it in GitHub Desktop.
Vim Sort Php Use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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