Created
January 11, 2015 16:26
-
-
Save fmoralesc/8f325886e835f8d1195a to your computer and use it in GitHub Desktop.
vim function to make conversions
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! Convert(pat, factor, orig_unit, conv_unit) range abort | |
try | |
execute a:firstline.','.a:lastline. 's/\('.a:pat.'\)\ze\s\?'.a:orig_unit. '/\=submatch(1)*'.string(a:factor).'/g' | |
execute a:firstline.','.a:lastline. 's/'.a:orig_unit. '/'.a:conv_unit.'/g' | |
catch | |
endtry | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment