Non-greedy regular expressions in Vim
For me its quite common that I want to substitute something in my buffer using a non-greedy regular expression. In VIM
this is done a little differently. Normally, I would use .? but that doesn't work in VIM.
Instead, you can use {-} instead of a to make VIM use a shortest match first algorithm.
As an example you can do this to unquote the keys in a JSON file:
:%s/\v"(.{-})"/\1
Here is an example of what that looks like in the package.json of this project:

This is something I find myself doing quite often. Whenever I work with a new API I usually curl that endpoint, pipe it
to jq for some nice formatting, and then redirect the output to a file. If I then choose to take a test driven approach,
and the response is dynamic enough to warrant tests for multiple variations, I might inline the fixtures as regular
javascript objects. I can then just copy that original JSON file and quickly execute a regex to unquote the keys.
The end
I usually tweet something when I've finished writing a new post. You can find me on Twitter
by clickingÂ