Is there any way to control indentation level for comments when reformatting code?

I have an issue at the moment with Webstorm's Code Style reformatting killing my comments, and I'm looking for a way round this.

My commenting style is to leave a tail; that way it's really easy to scan the page and quickly see what's going on:

However, WebStorm likes to re-align everything to previous block when you move stuff around - so If I drag or copy/paste the code above, a significant amount of reformatting goes on:

It could be said that I should get used to this (and perhaps modify my commenting style appropriately) but this is the first editor I've used to be this aggressive with reformatting. 9 times out of 10 it's really useful, but I've got used to this way of commenting as it really does make it easier to read a file, so I'm reluctant to give it up just because I've switched editors.

The only workaround I have at the moment, is Paste Simple (CTRL+ALT+SHIFT+V) which is pretty good. It would be great if there was a modifier key for dragging as well (Drag Simple?) such as SHIFT to simply shift the code from from one place to another without reformatting (edit: I've now filed a feature request for this).

Ideally though, it would be great if there were options in the code style prefs to manage this:

  • indent content following // comments (except if another // is detected of course)
  • alternatively, ignore // comments in refactoring, and respect any indentation of following content (I suspect this would be the easiest option)

Some feedback on this would be great, thanks.


1 comment
Comment actions Permalink

Have just discovered that...

     Settings > Editor > General > Smart Keys > Reformat on paste: None

...turns off Webstorm's handy reformat feature, both on Paste and on Drag :)

Would still love a reformat setting that intelligently ignores comments though!


Please sign in to leave a comment.