Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight lines that are too long

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

like image 299
Rose Perrone Avatar asked Dec 27 '22 03:12

Rose Perrone


2 Answers

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.

like image 88
Raystorm Avatar answered Jan 01 '23 21:01

Raystorm


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.)
like image 38
stbentley Avatar answered Jan 01 '23 20:01

stbentley