Vim regexp example: make a variable out of params

Today I wrote a regexp to change params[:page] into page. Here you are: :'<,'>s/params\[:\(\p\{-}\)\]/\1/g Let’s explain it briefly: the first part, :'<,'>s/, is the vim command to substitute a pattern (or a regexp) with another one. The <,'> part tells vim to operate on the visually selected text. the second part is the trickiest one. Let’s see it part to part: params\[: is the first part of the string we want to match....

July 9, 2012 · 2 min · metalelf0