Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij: Highlight current block of code

I was wondering if it is possible to highlight the block of code you are working on in Intellij Idea.

There was a similar question here: Is there a way to highlight the currently active code block in Visual Studio 2010? .

So what I mean is that if you have clicked into e.g. a method or a while loop... ,the background of the whole block becomes a bit lighter or whatever.

like image 827
max obermeier Avatar asked Jul 04 '16 13:07

max obermeier


People also ask

How do you highlight a block of code in IntelliJ?

Press ⌥↑ (macOS), or Ctrl+W (Windows/Linux), to extend your selection of code by scope. To reduce the scope, use ⌥↓ (macOS), or Shift+Ctrl+W (Windows/Linux). This can be useful for a visual representation of scope when moving blocks of code around.

How do you highlight lines of code?

If you want to highlight a whole line of text, move your cursor to the start of the line, hold the Shift key, and then press the Down arrow . You may also use the shortcut key combination Shift + End . If you want to highlight all text (the entire page), press the shortcut key Ctrl + A .

What is Ctrl Alt L in IntelliJ?

Sometimes code formatting can get out of sync, but there's an easy fix in IntelliJ IDEA. You can use ⌘⌥L (macOS), or Ctrl+Alt+L (Windows/Linux) to reformat a selection of code according to your reformat settings.


1 Answers

There's already one such feature, but it's more subtle, in the form of a vertical line inside the left gutter... I can't recall whether it's enabled by default or not, but you can activate it by File -> Settings -> Editor -> General, scroll to the Highlight on Caret Movement section (about half of the page).

I looked around for a while but I have not yet found a way to change its appearance to match your description, although I personally prefer this less intrusive highlight than having all the background changed.

Scope highlighting in action


P.S. Not sure this is relevant or useful to you, but there was a plugin I tried a while ago called CodeGlance which offered a scrollable-map of the class:

class map

like image 193
Morfic Avatar answered Sep 21 '22 00:09

Morfic