So I've recently moved from Eclipse to IntelliJ IDEA (Ultimate Edition) and I'm feeling fussy about whitespace.
At the moment I've set IntelliJ IDEA to show me whitespace, and it looks like this:
Eclipse would show the same code block like this:
Is there anyway I can make IntelliJ IDEA only show trailing whitespace, just like Eclipse can?
Most recent IntelliJ IDEA versions do support showing only trailing whitespaces:
Original answer from 2013:
IDEA has no this feature, but you can enable an option to strip trailing whitespace on all lines automatically and forget about this problem.
I would like to extend the existing answers.
As already mentioned, you can now show trailing whitespaces only (Settings → Editor → General → Appearance → Show whitespaces).
Unfortunately, in the Dracula theme those whitespaces are barely visible. What you can do, though, is to pick a better, more distinct, color (Settings → Editor → Colors & Fonts → General; then pick Text and Whitespaces). For some reason, you cannot change the background color which would be a great help.
As the question and the accepted answer are a little old, it's worth mentioning that recent versions of IntelliJ IDEA (only sure about v15) do support showing trailing whitespace only.
The setting can be found in Settings → Editor → General → Appearance → Show whitespaces. The options are Leading / Inner / Trailing.
I came upon this question searching for more granular whitespaces settings (e.g. show only spaces) and thought this clarification would help others.
Related
NetBeans has an option to show non-printable characters, but they are shown with the same vividness as printable characters. This means that a space and a dot are very hard to distinguish: the space is slightly raised, but otherwise visually identical. Many other code editors, and even Gedit, will show non-printing characters greyed out. Is there an option to do this in NetBeans, or do I have to file a bug report?
There is a different (and better) solution compared to my other answer, based on feedback from the OP: download and install the the Editor Whitespace plugin.
Its download page shows that it has not been tested for any version of NetBeans more recent than 8.0, but I have checked that it still works with NetBeans 8.2 and NetBeans 11.2.
To use the plugin:
Click the Download button on the plugin page to install the plugin in some arbitrary location.
In NetBeans: Tools > Plugins > select the Downloaded tab
Click the Add Plugins... button, navigate to the downloaded plugin, click Open, then click Install.
There is no need to restart NetBeans after installing the plugin. Just check the menu option View > Show Non-printable characters to immediately see non-printable characters in source code, excluding line break (¶) characters.
By default the non-printable characters are shown as black dots, but you can use any other color instead:
Tools > Options > Fonts & Colors > Syntax
Select All Languages from the Language drop list, and Whitespace from the Category list. You can select a specific language form the drop list if you prefer.
Using the Foreground drop list, pick the color you want to use to show the dots representing non-printable spaces.
Select Custom... to create your own color if you don't like any of the standard options.
The only benefit to using the plugin is that it suppresses the display of line break (newline) characters, but that is definitely worthwhile. If you have a specific requirement to be able to see line break characters, don't install this plugin, and just use standard NetBeans functionality as described here.
You can change the font color of whitespace characters to any color you want, either for a specific language, or for all languages. Here's how to do it for Java on NetBeans 9:
Tools > Options > Fonts & Colors > Syntax
Select Java from the Language drop list, and Whitespace from the Category list.
Using the Foreground drop list, pick the color you want to use to show the dots representing non-printable spaces. Select Custom... to create your own color if you don't like any of the standard options. As you scroll through the options for Foreground the color of the dots representing printable spaces in the Preview screen change.
Here's a shot showing the color being changed to magenta:
Notes:
The approach described above does not change the color of the line break character at the end of each line, and I don't think that is possible. That is arguably a bug, and at least a missing feature.
Although you can change the Foreground color at any time, it is only relevant when View -> Show Non-printable Characters is checked. Checking that option is also necessary to see the whitespace characters in the Preview screen.
The Background color for Whitespace can also be modified, but the result is invariably ugly and unhelpful.
Many editors and IDEs support converting spaces into tabs by using Tab/Shift+Tab on a line or a selected text fragment, but I've not found such a feature in Eclipse. Is there a plugin or something to add such functionality? I've tried to find one myself, but it doesn't seem to have any by keywords like "tab" or "indent". I'm working with Perl, BTW.
Check if the context menu has an entry like Source->Correct Indentation. That is available for Java, but the availability depends on the language you edit.
Otherwise you can install the AnyEdit Tools plugin which provides a command to convert the selection from tabs to spaces and vice versa.
If you change settings to tabs only or spaces only, Tab, Shift + Tab works as expected. (At least for me).
Scala allows to use the Unicode characters ← (\u2190) for <- and ⇒ (\u21D2) for =>
There are questions with answers on how to replace these characters (e.g. here and here) upon writing and even using post-processing (e.g. scala-style). These solutions however change the actual source-code. This means that if I'm using the Unicode style and my colleague isn't, we'll get a mix of styles in our source-code. Which in turn is something I dislike. (Meaning I'd rather use ASCII style arrows to prevent mixing styles.)
So I'm looking for a way to have a solution in the presentation-layer and not in representation. (like changing number-format using dot or comma for the decimal separator,.. it's not stored differently on disk.)
I'm aware that I could have Git do some funky stuff like it it does with line-endings for Windows, but I don't want to depend on Git for this. I just want IntelliJ (or Eclipse if someone knows how to fix it in Eclipse) to show me the Unicode arrows when it encounters the ASCII character version (preferably at the appropriate place, i.e. pattern-matching and for-comprehension).
Is this even possible in editors like IntelliJ and Eclipse? I'm willing to do some digging and writing plugins etc., but I'd rather not if it's not needed.
Since posting the question, IntelliJ has added native support to view arrows as if they are 1 character (called ligatures apparently).
From their whats new page:
We've added support for monospace font ligatures. To enable ligatures, go to Settings → Editor → Colors & Fonts → Font, choose a font that supports ligatures, e.g. FiraCode, Hasklig, Monoid or PragmataPro and select Enable font ligatures option.
If you want to see the lambdas as an arrow you can use the IDE settings.
I will go to IntelliJ Editor settings -> background, now enable the option "Enable ligatures".
One of the features I really like about Netbeans is that when you click on a variable, method, field etc. Netbeans shows you all the usages of this entity in the right hand bar as little bars of colour. Is there a way to get this behaviour in IntelliJ IDEA and if so, how do I turn it on? I haven't found anything in the settings or Google but I might be missing something!
file>settings or ctrl+alt+s (for windows) select editor from the list on the left and check Highlight usages of element at caret in the Highlight on Caret Movement section
Apart from enabling the "automatic highlight usages" setting described above, you can also invoke "highlight usages" manually, using the shortcut Ctrl+Shift+F7.
The benefits of using the "manual" highlight usages are:
You can highlight usages of multiple variables/methods/etc at the same time
You can remove highlighting for an individual element selectively, by invoking Ctrl+Shift+F7 again on that element
some users find it less distracting than "automatic highlight usage" - this is subjective or course
Above answers are correct but still to get the exact behavior like in Netbeans try to use Identyfier Highlighter plugin for Intellij Idea (available in default plugin list under window settings).
This is really strange as Idea features mentioned in previous answers would do the job if merged into the one configurable feature.
Is there a setting or plugin for eclipse that can show indentation guides in the editor? Something like the Codekana plugin for visual studio (not so fancy is also OK). Important that it works with PyDev.
EditBox since v0.0.20 is fixed for support Pydev. Thanks for reporting this. Some default preferences for Python included now, but you are welcomed to share yours here.
This can be achieved this is EditBox.
With some customization through it's preferences you can get to some nice code blocks highlighting of python code (or any other where blocks are signified with whitespace).
It is highly customizable and can achieve the vertical rules codekana style, and various other layouts.
The problem is it doesn't work on PyDev editor from what I see (at least for now). I've opened a feature request for it.
If it's any good, you can still view it's layout when opening a python file with right click "Open With/Text editor". From version 0.20, EditBox fully supports PyDev.
I also tried AnyEdit which has some whitespace highlighting amongst other features, but was not too happy with the results. For example, I had to press they're "show whitespace" button after each change to show the background, and it's not very visually pleasing (it uses eclipse's annotations to highlight whitespace).
IndentGuide is a plugin that does this for Eclipse. I am not sure whether it works for PyDev though.
The closest approximation would be to combine:
showing the whitespace characters (which shows tabs and spaces, but not just tabs)
code folding (available with PyDev)