How to disable auto changing tabs to spaces in the code in Intellij Idea? - 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.

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.

There is an option 'keep indents on empty line'

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

Besides noted IDE settings, please check if .editorconfig file exists in your project. The file may silently override IDE settings.

In Editor - Code Style - Java/JSON/etc - Tabs and Indents are two checkboxes:
Use tab character - when not checked, Idea replaces tabs by spaces while typing
Keep indents on empty line - when not checked, Idea removes tabs and spaces from lines where is no other content

Related

How to set tab indentation with GNAT GPS

I installed GNAT GPS 2017 and I would like it to indent my code with tabs using the same width as 4 space characters. I've gone into Edit->Preferences->Editor->Ada and tried all sorts of options (Use tabulations, default indentation 4, etc) but nothing seems to make it work:
Opening existing file with tabs causes GPS to display tabs with 8 spaces wide instead of 4.
Adding new code causes GPS to indent with 4 spaces but it inserts space characters instead of a single tab character.
Any ideas?
I think that GPS is working as-designed; unfortunately, that isn’t the way you want it to work.
The Preferences > Editor > Ada > Default indentation setting (and the four settings following it) say what screen appearance is required (assuming a monospace font, of course) if you hit the TAB key in a line.
The Preferences > Editor > Ada > Use tabulations setting says whether the editor should use 8-column-width tabs when possible to achieve the above.
#Jean-François Fabre suggested that "Their code parser doesn't support tabulations properly" - I think this may be that Jean-François compiles with -gnaty (style checks), and one of the default style checks is that the file isn’t indented with tabs.

Intellij indents 4 spaces when I have configured it to do 2 spaces (LESS)

On Intellij IDEA 14, I have tried to set my preferences in Editor > Code Style > LESS to do 2 space indents but no matter what I do, my code ends up getting formatted with 4 space indents. How do I get it to do 2 space indents for LESS?
If your project has an ".editorconfig" file, IntelliJ 14 uses that by default (which overwrites your settings). If you absolutely do not wish to use these settings, you need to disable the editorconfig plugin.
Not as likely, but if you make a scratch buffer and rename it to filename.ext. It does not honor the code style for *.ext, it defaults to tabs. You have to copy the scratch buffer to a real file and then it will apply the code style for *.ext.

How to make sublime text editor highlight left bar area on active code block

Sometimes I feal lost while coding on sublime text editor as it doesn't highlight the left bar as others ides/text editors do
what I am talking about is the light violet color on line numbers as in eclipse.
But in Sublime text Editor its simply an small dash beneath curly braces.
Is there any way I can get this in sublime text editor ?
Add this to your user, preferences file:
"highlight_line": true
You can find a great many helpful visual aids by looking in the default preferences file and the copying any over to your user file. Don't change settings in the default file though. Always add them to the user file.

intellij messes up with tabs in non-program files

so i just spent some time fussing over why my String.split call in scala failed - i was trying to split on a tab.
Problem wasn't what i was doing, but rather the fact that intelliJ changes tabs to spaces. Fair enough, but can i tell intelliJ to not do that for some files - like say random text files I might be using for test/learning purposes?
First, I would turn on Settings > Editor > Appearance > Show whitespaces, that way you're SURE what white space characters are there.
Next, under Settings > Code Style > General there should be a Use tab character check box. This says "use tabs for anything that's not Java, Scala, HTML, etc.". Just make sure Java, Scala*, etc. Use tab character setting is set to what you want.
Unfortunately, I don't know of any way to be more fine grained with what file types do and do not use tabs vs. spaces.
*I'm assuming the IntelliJ Scala plugin adds a tab in Settings > Code Style.

Is there a way to get eclipse to automatically detect a space/tab mismatch the way Visual Studio does?

In Visual Studio 2010, when I open a source code file that has a mix of tabs and spaces, a message will appear warning me as such and give me a chance to correct it. Is there such a feature in Eclipse whether native or via plugins?
I have not noticed such a feature, but there are settings you can change so you can detect it yourself. Essentially I show whitespace characters (specifically tabs and spaces). To show whitespace characters:
Preferences > General > Editors > Text Editors > Show whitespace characters
Click on the "whitespace characters" link to modify which whitespaces characters to show.
Then modify your language formatters to enforced tabs over spaces (or vice versa). Then when you format code (Ctrl+Shift+F) it will enforce the convention you set in your formatter. This has the other side effect of formatting the rest of your code, but that might not be a bad thing.
If you want to remove trailing whitespace when you format your code, you can do that by editing your "Clean Up" profile and clicking the "Remove trailing whitespace" option int the "Code Organizing" tab
Admittedly, this is not as nice as Visual Studio's solution and very similar to the answer above, but here's how I resolved this.
Go to Window > Preferences > General > Editors > Text Editors
Check the box "Show whitespace characters"
Click on "Configure Visibility"
Check the boxes under the Leading column for Ideographic space and Tab
Check the boxes under the Trailing column for Space, Ideographic space, and Tab
All other boxes should be unchecked.
"Ok" everything. You may have to reopen existing windows for this to take effect.
If you prefer having your code tabbed instead of using spaces, then you'll slightly modify these instructions to show leading spaces instead of leading tabs. In any case, having this set up as such gives me instant visibility when I have a file that uses tabs instead of spaces or mixed tabs and spaces.
I would not recommend using CTRL+SHIFT+F as it makes for a subversion nightmare when diffing old and new code. Alternatively, simply do a CTRL+F, check the Regex box, replace \t with four spaces. You'll still see a lot of diffs in subversion, but it's easy to pick out that you simply updated the spaces.