Last active
January 24, 2017 16:52
-
-
Save wellle/9233238 to your computer and use it in GitHub Desktop.
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
function! Group() | |
normal! l"ry$"ly0 | |
redir => message | |
execute "silent %g/\\V" . escape(@l, '/') . "/d" | |
redir END | |
let cnt = matchstr(message, '\d\+') | |
execute "normal! ggO" . cnt . ' ' . @l . ' || ' . @r . "\<Esc>0" | |
endfunction | |
nnoremap <silent> <leader>g :call Group()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Group similar lines around the cursor, similar to
uniq -c
. Example:With the cursor in front of
other details
press\g
to group all lines sharing the prefix left to the cursor, leaving the text to the right as example details:This is useful to quickly group tons of lines into similar groups based on common prefixes.