Any way to cause code to be highlighted for focus?

已回答

It would help me find my place in the code I'm working on as I scroll about, and help me maintain my focus on it, if I could mark some code and have it be highlighted in some way, either in the code itself or in the gutter.  As I'm imagining it, you could mark it with a simple comment like this:

////  <= that causes the following function to be highlighted in some way
fn method_I_am_writing() {
    // blah
}

Or if you put it inside a function, then it might highlight up to the next blank line:

fn method_I_am_writing() {
    ...
    ////
    // This gets highlighted
    let x += 1;  // and this

    // but not this
}

Is there any IntelliJ plugin or feature that can highlight text in some way like this?

0

Hi Nicholas,

Don't think we have context-aware highlighting support like this out of the box, but the Ctrl+M shortcut (Ctrl+L on macOS; corresponds to the action called "Scroll to Center") will quickly take you to wherever your caret currently is in the code.

You can also assign a different shortcut to it under File | Settings | Keymap:

Another option is to highlight certain lines manually using Bookmarks (F11 to toggle a bookmark on Windows). If you customize the color scheme for your bookmarks, you can e.g. have the whole line's background changed to a specific color when you hit F11.

You can also browse for custom UI theming plugins on Marketplace, like e.g. Material Theme UI. They may have some settings related to this.

0

Those are helpful suggestions, Arina; thanks.  I'll try them out.

Do you know enough about the plugin API to know whether it would be relatively straightforward to do what I suggested?  It would have to be able to recognize some special comment, to know whether the comment precedes a function definition, to look forward through lines for a blank line or the end of a function, and to set highlighting for a range of lines.  Or something like that.  If it were a relatively easy kill, I might look into it as something to do in my non-existent spare time.

0

Happy to help Nicholas.

Check out the IntelliJ Platform Plugin SDK guide for details on how to use the plugin API:

0

请先登录再写评论。