I have this at the top of my file:
var server = require('http');
var watchr = require('watchr');
var io = require('socket.io');
var fs = require('fs');
I want to convert this garbage to the corresponding var list:
var server = require('http'),
watchr = require('watchr'),
io = require('socket.io')(server),
fs = require('fs');
So, my first step is to find all the ads varin this paragraph , except the first , and put them off. Therefore, I am looking for every word varthat precedes another varin the previous line.
Here's a regex that for some reason works:
\vvar\_.{-}\zs<(var)@>
Explanation:
\v Very magic mode (make all special characters special)
var The word var
\_ Spanning multiple lines
. Any charaacter
{-} Non greedy
\zs Actually start higlighting our search here
< A word boundary
(var) The second occurance of the word var
@> Treat the previous thing (var) as the whole match. Otherwise
Vim is too stupid to match consecutive lines and only
matches every other line
Now that I hit nin my file, Vim correctly jumps to every statement var except the first one. Hooray!
:g , ( , , n )
v i p :
'<,'>g
:
var server = require('http');
var watchr = require('watchr');
var io = require('socket.io');
var fs = require('fs');
? ? g zs @> - Vem regex, ?