Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Detecting Dangling Commas in JavaScript

by bellaire (Hermit)
on Jan 20, 2011 at 18:26 UTC ( #883383=note: print w/replies, xml ) Need Help??


in reply to Detecting Dangling Commas in JavaScript

Nice! Thus, to map this replacement to a vim command (using a vim with perl support):
:command FixCommas perl $s=join(qq{\n},$curbuf->Get(0 .. $curbuf->Coun +t()));$s =~ s#^((?:[^/\n]|/(?!/))*),((?:\s*|//.*$|/\*(?:[^*]|\*(?!/)) +*\*/)*\s*[}\]])#$1$2#mg; $curbuf->Set(0,0,split(qq{\n},$s));
(Tried it as a simple :%!perl -pi -e at first, but vim hated the # characters.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://883383]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2019-10-20 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?