Skip to content

Instantly share code, notes, and snippets.

@timsuchanek
Created January 21, 2016 19:46
Show Gist options
  • Save timsuchanek/f2f282e27d53898faaee to your computer and use it in GitHub Desktop.
Save timsuchanek/f2f282e27d53898faaee to your computer and use it in GitHub Desktop.
vim regex for converting from js prop syntax to Immutable.js syntax
# converting
# lines[1][2] = 'asd'
# to
# .setIn([1,2], 'asd')
# mark the lines with V, then type :
# the following will appear:
# :'<,'>
# continue with
# s/\varname\[\(\d\+\)\]\[\(\d\+\)\]\s=\s'\(.*\)'/.setIn([\1, \2, '\3')/g
#so you get
:'<,'>s/\varname\[\(\d\+\)\]\[\(\d\+\)\]\s=\s'\(.*\)'/.setIn([\1, \2, '\3')/g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment