Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable auto changing tabs to spaces in the code in Intellij Idea?

How to disable auto changing tabs to spaces and removing empty lines, whitespaces in the sourcefiles after it opened?

In other words if the line contains tabs and spaces in one line Idea shouldn't change them. For example if file contains "-->-->....-->public void setAttribute();" Idea shouldn't change tabs to spaces or spaces to tabs. I can disable all autoformattig.

like image 420
Maksym Kartsev Avatar asked Mar 23 '15 08:03

Maksym Kartsev


People also ask

How do I stop auto formatting in IntelliJ?

In Preferences > Editor > Code style > [language] uncheck reformat on file save .

How do I change the tab spacing in IntelliJ?

To toggle between tabs and spaces: On the main menu, choose Edit → Convert Indents, and then choose To Spaces or To Tabs respectively.

How do I pin tabs in IntelliJ?

Pin or unpin a tab To pin or unpin an active tab, right-click it and select Pin Tab or Unpin Tab from the context menu. To close all tabs, but the pinned ones, right-click any tab and select Close All but Pinned.


3 Answers

To restate the problem, you want the editor to not affect the whitespace indentations. Spaces should remain spaces and tabs should remain tabs.

I'm having a similar problem. It looks like IntelliJ has this feature:

Settings > Editor > Code Style, Indents Detection section, Detect and use existing file indents for editing option

Unfortunately, I don't think I can get it to work as expected for myself (version 2016.3.6), but it seems to be working for others.

Here's the original jetbrains blog post about it.

like image 59
kugo2006 Avatar answered Oct 19 '22 09:10

kugo2006


There is an option 'keep indents on empty line'

enter image description here

like image 22
bzak Avatar answered Oct 19 '22 07:10

bzak


Assuming Java: Settings > Code Style > Java > Tabs and Indents > Use tab character. You can do the same for other languages too.

like image 45
acanby Avatar answered Oct 19 '22 08:10

acanby