Skip to content

Instantly share code, notes, and snippets.

@fmoralesc
Created January 11, 2015 16:26
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 fmoralesc/8f325886e835f8d1195a to your computer and use it in GitHub Desktop.
Save fmoralesc/8f325886e835f8d1195a to your computer and use it in GitHub Desktop.
vim function to make conversions
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