Created
September 18, 2011 04:16
-
-
Save urubatan/1224723 to your computer and use it in GitHub Desktop.
VIM function to save the selected range to a file and replace the contents with a pointer to the file. Goot to be used with http://github.com/urubatan/codemerger
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! ExtractText(fileName,first_line,last_line) | |
let text = getline(a:first_line,a:last_line) | |
execute ":" . a:first_line . "," . a:last_line . "delete" | |
execute "normal O{{" . a:fileName . "}}" | |
return writefile(text, a:fileName) | |
endfunction | |
command! -range -nargs=1 Es call ExtractText(<f-args>,<line1>,<line2>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Forgot to say, to use it, select visually a range :Es newFileName