Advertisement
Guest User

Untitled

a guest
Oct 28th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 0.76 KB | None | 0 0
  1. global !p
  2. def VinLudens():
  3.     import re
  4.     CurrentLine = snip.buffer[snip.line]
  5.     Pattern = re.compile("[^:,]+")
  6.     LiteralSnippet = ""
  7.     Index = 1
  8.     snip.buffer[snip.line] = ""
  9.     for j in Pattern.findall(CurrentLine):
  10.         LiteralSnippet += (j + " = $" + str(Index)  + "\n")
  11.         Index += 1
  12.     snip.expand_anon(LiteralSnippet)
  13. endglobal
  14.  
  15.  
  16. # |TODO|: Find out how to make the first placeholder to set the cursor in its
  17. # correct position (it appears one character behind its correct position
  18.  
  19. pre_expand "VinLudens()"
  20. snippet "^:.+:$" "" rA
  21. endsnippet
  22.  
  23. # SNAP
  24. # ===============================
  25. # -> :1,2:<tab>
  26. # a =$1
  27. # b = $2
  28. # ===============================
  29. # -> :1,2,3,4,5:<tab>
  30. # 1 =$1
  31. # 2 = $2
  32. # 3 = $3
  33. # 4 = $4
  34. # 5 = $5
  35. # ===============================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement