Relative indent of java method body disappears after I clone a project from gitlab without modifying any code

Viewed 76

I clone the java code from gitlab firstly. Then I open one of the java classes with a editor without modifying any code. I find the relative indent of every method body disappear in any java class. I tried to open the class with more than one editor, including intellij idea, sts, notpad++. But When I use notpad which is installed in win10 natively. It goes as expected. This is the result opened by intellij idea, sts, notpad++: enter image description here

public ElasticSearchRepository(Class<E> entityClass) {
this.entityClass = entityClass;
}

This is the result opened by notpad in win10:

public ElasticSearchRepository(Class<E> entityClass) {
   this.entityClass = entityClass;
}
1 Answers

This is a difference in the indent settings of the default number of spaces in a TAB character.

A. Intellij

In IntelliJ you can do this

File > Settings > Editor > Code Style > Java > Tabs and Indents > Use tab character

B. VSCode

  1. Go to Code > Preferences > Settings if you’re using macOS (shortcut: Command + ,).
  2. Go to File > Preferences > Settings if you’re using Windows (hotkey: Ctrl + ,).
  3. Type Indentation into the search field then head to the Editor: Tab Size section. Replace the default space number with your preferred one:

C. Atom

  1. In Atom, open preferences or CMD + ,
  2. Click on Editor on the left pane.
  3. Scroll down to Tab Length and input what you prefer.

D. Notepad++

To change the default action of the tab key:

  1. Click on the Settings menu
  2. Select Preferences
  3. Go to the Language Menu/Tab on the left Settings pane.
  4. Make sure [Default] is selected in the rightmost list.
  5. At The bottom right, there's a checkbox labelled Replace by space. You can check this to use spaces or set the nomber of spaces for your tab character above this option.

E. Komodo Edit

  1. Open up Preferences. On mac it's simply Command + , and on PC, hopefully control + p.
  2. Click on the arrow beside Editor to bring down the further categories for it.
  3. Select Indentation.
  4. Simply enter the desired number of spaces for indents in the appropriate window and hit OK at the bottom.
Related