Skip to content

Instantly share code, notes, and snippets.

@Raimondi
Created September 29, 2010 08:59
Show Gist options
  • Save Raimondi/602477 to your computer and use it in GitHub Desktop.
Save Raimondi/602477 to your computer and use it in GitHub Desktop.
" Will write text including first match until before the second match:
" :WriteMatchedText first second /path/to/file.ext
function! WriteMatchedText(first, second, file)
exec "normal /".a:first."\<CR>"
normal v
exec "normal /".a:second."\<CR>h"
normal y
call writefile(split(@", "\n"), expand(a:file))
endfunction
command! -bar -nargs=+ -complete=file WriteMatchedText call WriteMatchedText(<f-args>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment