Using Scala & IntelliJ, show unicode arrows but don't change source-code - scala

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

Related

How to add support for a custom non-unicode font in VSCode?

I have a custom fantasy script which looks like this (just the text portion):
It is a monospaced font built with FontForge. How can I add support for it to VSCode, so I can type in ASCII (like the left side here), and it outputs the random UTF-8 symbol mapped to the custom font in VSCode? So I can then save the file and have it be either a bunch of gobbledygook characters or the ASCII characters I originally typed?
Ideally this could be a plugin, so if you know of an open source VSCode plugin which I could use as inspiration, that would be a perfect answer as well.
I see how to set a custom font in VSCode, but (a) that is globally, and (b) it doesn't necessarily solve the typing problem. I just really would like to know how to do this, not necessarily requiring an answer to implement it.
Recommended UX is to have a "separate keyboard" for it, meaning typing the keys on the keyboard would result in different values. Maybe something like that can be done on a per-file basis?

Convert tabs into spaces

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

Show only trailing whitespace in IntelliJ Idea

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.

Syntax-dependent fonts in Eclipse?

Notepad++ has the ability to show some types of syntax (e.g. strings) in a different font from others.
Can Eclipse do something like this?
I need this ability because the strings have Unicode characters in them, but all the fonts that I have that support Unicode look crap in the rest of the code.
EDIT: I am looking for this feature for Java code.
Not currently possible, you can only change the font family for the entire Java editor.
it depends on which perspective .. I am using PyDev .. go to window-->preferences then select PyDev tab then select Editor ..you will find a panel titled with "Appearance color options" .. you can customize the color of each part of your codes

Setting up your editor: indentation and encoding

I'm developing a small project with some friends and we're facing some indentation issues. Each of us is using a different editor (we all have different favorites :) and we also are on different operating systems.
What is the best solution to be able to all develop together and set our programming editors so indentation and encoding is the same? What settings do you recommend and why?
You should have your version control system handle the line ending problems. In SVN, the "svn:eol-style" property can be set to "native" to handle auto-converting the line endings. I assume your code is ASCII or UTF8 so you don't have problems with character encoding.
As far as formatting goes, you'll have to choose roughly some style, such as where to put the braces, but there's no reason you have to have the same indent style, provided you use the same number of indents. That's a confusing statement, so allow me to explain: nearly every IDE ever has the ability to set tab widths to any value you want. If one team member likes to indent 2 character widths, another 4, that's fine. One tab character stored in the file can display either way based on IDE settings. Just configure your IDE to indent with tabs and then set the tab widths per your desires.
(at the risk of starting a flame war, this is why I am solidly in the camp of tabs in the tabs vs spaces war. strangely, the spaces folks seem to consider this very feature the reason to use spaces... I will never understand them).
If you are all insistent to have your own indentation settings, then you will need to use exclusively the tab character to indent the code. (Provided your various editors support this).
This approach is counter to the general consensus of using spaces and only spaces for indenting purposes.
Whatever you do, I recommend converting tabs to a common number of spaces. I know Eclipse can do this on the fly, but I'm not sure if edits like gvim can. In any case, with all spaces it is not up to the individual editors/IDEs to interpret how many spaces make up a tab. Also, if anyone's using a Windows editor/IDE, set it to use Unix-style newlines, so that you don't get the annoying ^M at the end of every line when you edit in a different OS.