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).
Related
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".
I've followed all the suggestions here.
When I press return, I get a new line that is indented with tabs instead of spaces.
If I backspace to clear the tabs, and then press TAB a series of times, it correctly indents with spaces.
I'm pretty sure I have all my settings set up correctly. I created a new Code Style > Formatter policy for every language in the project, and specified to always use spaces. It seems as though these settings are partially active (ex: when I press tab), but inactive when I use return. I tried restarting Eclipse. I'll try restarting the computer now...
I'm using Mac OS X 10.9.2 and a Liferay Developer Studio (1.6.3.v201312111844) version of Eclipse (not sure which Eclipse build its based on though).
Can anyone think of another setting/solution to ensure that newlines are created with spaces instead of tabs? I recently saw http://editorconfig.org/, and I'm wondering if there's some interference.
Thanks for any suggestions
If the file has existing lines that are using tabs, then Enter will respect that and try to create new lines in a similar way (see this comment by topchef for a solution). Also, it could be something in Liferay Studio's proprietary settings is overriding Eclipse standard preferences (as suggested by user John).
Keep in mind that each type of editor in Eclipse can have its own preferences and perhaps that's what you're running into here. You can try to find them all by opening Preferences and searching for "indent" in the search field. That will show all the preferences pages where indentation can be configured.
Also note that the Formatter settings don't have any affect on as-you-type formatting; that's for when you select a file or group of files or part of a file and choose Source > Format from the menu.
working in eclipse,when I type 'tab',it insert 4 spaces,it works well.but after ctrl +shift +f to format,all the 4 space will been replaced by tabs.how to stop it?
Window->Preferences->Java->Code Style->Formatter: Edit Active profile->Indentation->Tab Policy: Select Spaces
You can't change the default profiles so you must provide a new profile name, then press the Apply button, then the Okay button. It may help to press the Apply button once you have returned to the Formatter screen. Go back and look at the Tab Policy again to verify that your changes were saved.
Including the above suggestions, I recommend searching for code style or style to get to the coding standard being applied with the user requests formatting of the code. It is possible that the code style uses tabs instead of spaces.
The only way that currently works is to use Ctrl-A Ctrl-X Ctrl-V on all code after using Ctrl-Shift-F. This will replace all tabs with spaces.
Don't know which version of Eclipse you are using but for
Eclipse 3.6 (for example) you may go to
Window->Preferences->General->Editors->Text Editors->Insert spaces for tabs
This will change Eclipse to use spaces instead of tabs
The place in the Preferences may be different depending on which version of Eclipse you use. If you load the preferences window you can use the search function there to find "Formatters" and set your preferences for different types of files, or generally.
I feel very silly asking this question, but here goes. :)
I've configured Eclipse to insert spaces instead of tabs, but I'm working on a Makefile, which requires literal tab characters (see Can you make valid Makefiles without tab characters? for a good explanation).
So how do I type one, short of opening the Text Editors preferences, unticking the "Insert spaces for tabs" option, clicking Apply, and then undoing all of that when I'm done editing the makefile?
Only way I can find to do it in Eclipse (version=Juno) was to type say XXX where I wanted the tab character and then do a find/replace. Switch on regexp matching in the find and put XXX as find with \t as the replace. Painful but works.
If you're using the Eclipse's built-in Makefile editor (included in the C++ package I believe), tabs should be literal.
Sorry, I don't appear to have enough points to comment on the accepted answer, but I wanted to add that although the Makefile editor allows tabs to be entered, it doesn't use tabs when indenting multiple lines with the tab key, or if you enter a tab in block selection mode. This made me think I couldn't enter tabs for a while (I should probably raise a defect report).
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)