How to set tab indentation with GNAT GPS - 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.

Related

IntelliJ IDEA: how to fix broken font display?

Unable to read the language. How to set it to english ?
The issue is not with the language, but with some broken font mapping on your system. The workaround is to change IDE font. Press Ctrl+Alt+S to access the Settings dialog, open the second entry from the top and set some font here:
Had same issue with IntelliJ Community Edition, version 2019 2.
Initially the only way I could get the "normal" IntelliJ charset mapping to persist after closing and reopening is go to Settings > Appearance & Behaviours > Appearance and then to UNCHECK Use Custom Font and allow the built-in defaults to be applied.
Later I discovered that I could use all custom fonts except my favorite, Open Sans.
Somehow selecting and applying this font only worked for the remainder of the IntelliJ session. If IntelliJ was closed and reopened, the character mapping was altered in both the Settings page and in the IDE. Each character was represented by the next character alphabetically, e.g. Open Sans ==> Pqdo Tbot
Notice that the first letter of the menus (which has a separate formatting as it's underlined) remains the same while the remainder of the menu title is ampped to the next letter in the alphabet.
The question thus arises: why is Open Sans showing this change of character mapping while other fonts do not ?

Can I make IntelliJ IDEAs auto indent ignore previous lines?

Auto-indenting in IntelliJ IDEA seems to automatically takes lines previous to the selection in to consideration. This means that if the indentation is incorrect in the part of the file you're working on (e.g., 3 or 5 spaces where there should be 4, or even worse, a mix of tabs and spaces) it's annoyingly difficult to add correctly indented code.
Both new lines I'm adding and lines I use auto-indent on because I've changed them anyway get messed up like this. Since the file I'm working on is being worked on by someone else as well on another branch, I really don't want to modify over a third of the file just to indent everything correctly, but I would still like the lines that I'm actually modifying/adding to be correct - I don't see any reason to perpetuate the error when it's not necessary.
Currently the best mechanism for fixing it I've found is to manually do the spaces on a line and go from there, but it's really quite annoying, especially since I can't use the tab key or IntelliJ will immediately move to the incorrect indentation. It's barely better than copy/pasting the text to Sublime Text, fix the indentation there and paste it back without formatting.
My apologies if this has already been asked, I've tried to search for it, but it's very hard to search for this as there's so many auto-indent questions.
IntelliJ IDEA recently added a feature (in v14 or 1v4.1 if I recall) where it will detect indentation that is different from your settings. It will honor those indentations (in order to keep the file consistent). Usually as soon as you start editing the file, you get a banner, although that can be turned off. The banner looks like this:
This allows you to modify this setting on a per file basis, or turn it off completely (i.e. the "Show Settings" option).
I suspect this feature is what is causing you the issue. I am not sure how it handles a case where a file has mixed indentation (e.g. most of the file is 4, but some sections are 3 or 5 spaces). You can try turning this feature off in Settings > Editor > Code Style > "Detect and use existing file indents for editing"

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.
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

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.