Highlight lines that are too long

4.1k Views Asked by At

In vim, I can create a rule that highlights lines that are over 80 characters long. Can I do this in IntelliJ? Here's an example in vim:

vim example

4

There are 4 best solutions below

0
On

I'm sure you've have already resolved this, Rose, but for other people who stumble upon this post, Raystorm's answer was correct. However, in order for the automatic line wrapping to occur, you must auto-format the code by typing Ctrl-Alt-L.

0
On

IntelliJ (at least v2016.2 and newer) has exactly this feature.

  • Under preferences go to: Editor -> Inspections -> General,
  • Then select: "Line is longer than allowed code style". You can choose the severity you want, for most severities IntelliJ will underline the characters that exceed the line length limit (but you could change the style of the severity to look exactly like vim if you wanted).
  • (If it doesn't work, make sure "Right margin (columns):" is set under preferences Editor -> Code Style.)
0
On

You could add the JSLint Code Quality Tool.

You can set a maximum line length with that tool... if you so desire, you could disable everything else.

Then, in the Inspections part of your Project settings, enable the JSLint Inspection and set it to whatever Severity you like. This will probable highlight the whole line, but that's close enough, right? :)

2
On

I don't know if you can highlight. You might have to write a custom Code Inspection for that. But in Settings -> Code Style you can set a right margin of 80 characters and force automatic wrapping once you reach it.

Infact in Settings -> Code Style -> Java under the Wrapping and Braces Tab
there is the option Ensure right margin is not exceeded.