Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The following code is taken from the superfish module for websites:

(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))

And once upon a time when editing this kind of file, I once accidentally hit a shortcut key that restructured the code:

(function($){$.fn.hoverIntent=function(f,g){
 var cfg={sensitivity:7,interval:100,timeout:0};
 cfg=$.extend(cfg,g?{over:f,out:g}:f);
 var cX,cY,pX,pY;
 var track=function(ev){cX=ev.pageX;cY=ev.pageY;};
 var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);
 if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity
  {$(ob).unbind("mousemove",track)
  etc..........

I want to know what that shortcut is o.0

It's like the formatting already exists but VI didn't render it?

share|improve this question
add comment

1 Answer 1

The vim command to format source code is gg=G, it always worked for me with java or c source code; it does not work with your snippet probably because it only works with syntactically correct files.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.