4coder » Forums » Annotations and indentation in java
Jonas
2 posts
#16539 Annotations and indentation in java
1 month, 1 week ago Edited by Jonas on Oct. 12, 2018, 7:45 p.m. Reason: Initial post

Hi!

I was wondering if there is an easy way to fix the indentation after annotations in java files. As per now, it indents the next line. I have been looking through the customization code, but I am at a bit of a loss of what to do. Could anyone help me out?

Right now it looks like this.
1
2
3
@Override
    public void method() {
}


I would like it to look like this.
1
2
3
@Override
public void method() {
}
Mr4thDimention
Allen Webster
428 posts / 2 projects

Heyo

#16541 Annotations and indentation in java
1 month, 1 week ago

First, it depends on in you're using virtual whitespace. Virtual whitespace is on if you can't delete and insert individual spaces at the beginning of a line. If you are using it, there's nothing you can do, it's not customizable.

You can disable virtual whitespace in config.4coder if that's what you want.

If you've disable virtual whitespace then you're looking at the text level indenter. In that case there is something you can do by editing 4coder_auto_indent.cpp. Lines 504 through 506 add extra indentation whenever the parser thinks it has seen an incomplete statement. Either just comment that out, or enhance the parser to think of @Override as the end of a statement, which is not necessarily an easy task, but possible somehow I'm sure.
Jonas
2 posts
#16545 Annotations and indentation in java
1 month, 1 week ago Edited by Jonas on Oct. 13, 2018, 10:46 a.m.

I am using virtual whitespace, and I don't really want to disable it. It's not a problem for me as I'm not really working that much with java. I was just curious if there was a somewhat easy fix somewhere in the customization code.

Anyways, thanks for the quick response. :)
KiloPasztetowej
Maciek
10 posts
#16546 Annotations and indentation in java
1 month, 1 week ago

Hey. Create your custom 4coder command that’s replacing return key. Firstly exec command that’s currently bound to it, and secondly, remowe the whitespace. That’s really easy to do with 4coder api.