Guest User

Untitled

a guest
Apr 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. command -range NativeTraits :<line1>,<line2>call NativeTraits()
  2.  
  3. function! NativeTraits() range
  4. if match(getline(a:firstline), "has") == -1
  5. throw "This does not look like a has block"
  6. endif
  7.  
  8. let range_has = a:firstline . "," . a:lastline
  9. exec range_has . "sm/metaclass.*=>.*Collection::\\(\\w\\+\\).*,/traits => ['\\1'],/"
  10.  
  11. call cursor(a:firstline, 0)
  12. let pfirst = search('provides\s*=>\s*{', "nW", a:lastline)
  13.  
  14. call cursor(pfirst, 0)
  15. let plast = search('^\s*}', "nW", a:lastline)
  16. let range_prov = pfirst . "," . plast
  17.  
  18. exec range_prov . "sm/\\(\\w\\+\\)\\s*=>\\s*'\\(\\w\\+\\)'/\\2 => '\\1'/"
  19. exec range_prov . "s/provides/handles/"
  20. endfunction
Add Comment
Please, Sign In to add comment