Wrap Comments and Text to Column Width in IntelliJ Editors

May 19, 2013

One of the small annoyances I found after switching to PyCharm recently was that while the editor will reformat code to the chosen column width, it won’t wrap plaintext or comments. Annoying, for Vim and Emacs users!

I corrected this by writing my first IntelliJ plugin: Wrap to Column, which is a port of a different plugin I wrote for the same feature in Sublime Text 2. It should work with any JetBrains editor based on Intellij IDEA (PyCharm, WebStorm, PHPStorm, RubyMine, etc.).

The “Wrap to column” command wraps selected text or the current line to the column width you’ve configured for the project. The goal is to match the functionality of Vim’s “reformat lines” (gq) command and “fill paragraph” in Emacs.

Just so you know, there is a “fill paragraph” command in IntelliJ — something they added in recent months — but I’ve not been able to get it to do anything but merge all selected text into a single line that is longer than my column width setting. After filing bug reports and sending emails, I gave up and wrote the feature myself, since I’d already done so once before.

If you end up using it, drop me a line or comment on the plugin page if it’s working for you. I could use more testers!