Skip to content

Instantly share code, notes, and snippets.

@mattboehm
Created February 26, 2015 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattboehm/da63a48eedf6f14375aa to your computer and use it in GitHub Desktop.
Save mattboehm/da63a48eedf6f14375aa to your computer and use it in GitHub Desktop.
function! SplitRegex()
    tabnew
    setlocal buftype=nofile bufhidden=hide noswapfile
    let numlines=len(@")
    execute "normal! V".numlines."pggjl"
    let tmp=@z
    let @z="hv0r wlv$r j"
    execute "normal! ".(numlines-2)."@z"
    let @z=tmp
    execute "normal! gglv$r\<space>"
    xnoremap <buffer> <SPACE> <Esc>:let tmp=@/<CR>gvJ:s;\S\zs\s\+\ze\S;;g \| let @/=tmp \| unlet tmp<CR>
    nmap <SPACE> Vj<SPACE>
endfunction 
xnoremap ,r y:call SplitRegex()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment