Last active
December 14, 2015 22:49
-
-
Save branquito/5161434 to your computer and use it in GitHub Desktop.
VIM copy matches into register
This file contains hidden or 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! CopyMatches(reg) | |
let hits = [] | |
%s//\=len(add(hits, submatch(0))) ? submatch(0) : ''/ge | |
let reg = empty(a:reg) ? '+' : a:reg | |
execute 'let @'.reg.' = join(hits, "\n") . "\n"' | |
endfunction | |
command! -register CopyMatches call CopyMatches(<q-reg>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment