I like to display 4 spaces as tab in eclipse, with an actual width on the screen of 2 spaces.
When I save the file, I'd like to have 4 spaces (represented as «.») for a tab:
1st.level
....2nd.level
........3rd.level
In eclipse, I'd like to see this, where a tabstop (represented as «->>») should take the width of two spaces:
1st.level
->2nd.level
->->3rd.level
Is such a behavior possible? Does someone know any addons for that?
Thank you in advance,
~Chris
AnyEdit tools sounds like what you might need.
Open "Preferences" -> "General" -> "Editors" -> "Text Editors"
Set "Displayed tab width" to the number of spaces you would like it to insert.
Tick the Box that says "Insert spaces for tabs"
Related
I have many source code files which are idented with 8 space characters, I want to convert these to 4 character indents. What is the best way of doing this? A technique using eclipse would be preferable.
Select the project(s), then press Ctrl+H to open the Search dialog (or click the Search > File menu).
Make sure the File Search tab is selected at the top.
Enter 8 spaces into the Containing text: field
Select your File name pattern (probably *.java or just *)
Select the scope (probably Selected Resources)
Press the *Replace... button.
As I said in the comments above, however, using spaces for indentation is a fool's game; tabs are the proper abstraction for indentation so that you don't have this problem.
Is there any way in Eclipse (Galileo 3.52) to have it replace tabs with spaces ("soft tabs")? I've tried two things so far . . .
Windows>Preferences>Editors>Text Editors... check "Insert spaces for tabs"
...and...
Window->Preferences->Java->Code Style->Formatter->Edit... "Use Spaces to indent wrapped lines"
(... this forces you to create a new profile to save these settings)
This produces partial success - the first tab is turned in to spaces but subsequent ones are still tabs. So if I type
tabtab 1234
...I end up with...
spacespacespacespace tab 1234
You can do:
Window -> Preferences -> Java -> Code Style -> Formatter
Click on “Show” button (or "Edit") right beside the name of the profile you are using.
In the indentantion Tab, change the "Tab Policy" field to "spaces only"
Click Ok, and save the profile with the name you want.
Could the missing setting be the Tab policy: Spaces only combo box in Preferences >Java > Code Style Formatter > Edit > Indentation (right above where you changed Use spaces to indent wrapped lines)?
I have a specific project where I need to wrap every code line at 65 characters. I have set up the eclipse Java code formatter properly for this. But what I really want is a vertical line to be drawn in the editor showing where the max line width while I am typing, not just when I run the formmater. I know this feature is available in some capacity because it is displayed in the code formatter property page.
I don't see any option in eclipse to turn this on and I didn't see any plug-ins that do it on Eclipse Plugin Central
Look in Windows / Preferences (at least on Windows - IIRC it moves around for different operating systems) then:
General -> Editors -> Text Editors -> Show Print Margin
Tick this and it should show the line.
As a quick way of finding this, use the search filter in the top and filter on "margin".
Notes from the comments - unverified by me, but I have no reason to doubt them:
It has changed somehow in 2016: For details see [here] (https://bugs.eclipse.org/bugs/show_bug.cgi?id=495490#c2) You have to set it in the formatter: From menu [Window]-->[Preferences], select [Java]-->[Code Style]-->[Formatter], and then edit your formatter profile. In the tab page [Line wrapping], you can find a setting named "Maximum line width". Change this setting, and the print margin in Java source editor will be changed too.
In Eclipse Luna (4.4):
Choose menu Window\Preference . Look at top-left corner, in search box type filter text, type: margin.
In section Apperance color option, Choose Print margin. Choose Show print margin. In text box Print margin column , type 65 as what you want.
#Jon Skeet's answer is incomplete.
(1/2) First, do what he said:
Window --> Preferences --> General --> Editors --> Text Editors --> check the box for Show Print Margin
Ticking this box will show the vertical line.
As a quick way of finding this, use the search filter in the top and filter on "margin".
However, this only shows the line, but under most situations the "Print margin column" value there is flat-out ignored.
To set the column number for where the line should be, do what #John Percival Hackworth mentions here:
(2/2) Go to:
Window --> Preferences --> C/C++ [or whatever language you are using] --> Code Style --> Formatter --> click Edit --> under the Line Wrapping tab set the value you desire for Maximum line width.
Side note:
Use Alt + Shift + Y to toggle soft line wrapping on and off. It will soft wrap (ie: no carriage return) at the end of the screen, however, not at the column you set above.
How do you enforce hard line wrapping at the column you set above (ie: that adds a carriage return)? I don't know yet. If you figure it out let me know. In Sublime Text 3 (a much better editor but with a much worse indexer/function definition finder :() it's Alt + Q.
Update: I think it may be possible with the "CppStyle" plugin, which uses clang-format, by using Ctrl + Shift + F to apply the auto-format, but I don't know the exact instructions to make it work yet.
Related:
Set tab width: Changing editor tab width in eclipse 3.5
After some months with Espressif, but also with other brands plugged-in Eclipse, I found how to enlarge maximum line width. I made a lot of attempts and show how to do for Espressif-IDE:
Right click a project->properties->C/C++ General->Formatter
->Enable Project specific settings->
New->Give your profile a name and base it on a built-in formatter: I choose BSD/Allman->Edit this new profile->within Line Wrapping tab type for example 200 for Maximum line width->Apply changes.
Format source files: you'll have long lines.
Before I did the same manouvres starting from:
Window->Preferences->C/C++->code Style->Formatter... : that never worked.
When I hit Tab for indenting code, I like to get a real tab. Meaning that when I select that, I only have one large thing selected. NetBeans inserts 5 spaces instead of a tab when I hit Tab. Is there a way I can change that?
Go to Tools-> Options-> Editor-> Formatting and uncheck Expand tabs to spaces:
Ensure you also pick coherent values for "Number of Spaces per indent" and "Tab Size".
Additionally, you can check all the items in the Language combo and make sure they all use the general setting.
You can also change it in a per-project fashion. Right click on the project icon, select Properties and review the Formatting category.
These menu items remain valid as of NetBeans 8.0.
It seems to work if you select the same value for "Number of Spaces per Indent" and "Tab Size", after unchecking the "Expand Tabs to Spaces" Option, in Tools -> Options -> Editor -> Formatting, for example:
[ ] Expand Tabs to Spaces
Number of Spaces per Indent: [ 4]
Tab Size: [ 4]
....
For NetBeans 7.1.2,
I needed to go to Tools -> Options -> Editor -> Expand Tabs to Spaces and uncheck that one (make sure you have "All Languages" selected). And also put an "8" for both Number of Spaces per Indent and Tab Size.
Just having the same value there does not do the trick for me. It must be 8.
In Tools-> Options-> Editor-> Formatting Expand tabs to spaces should be unchecked and Number of Spaces per Indent should be equal with Tab Size. Also check when you change Language from All languages to other there Override Global Options should be unchecked, too.
Netbeans IDE 8.2 (OSX)
Goto File -> Project Properties (Your Project)
Select Formatting in Categories:
Click on Edit global options.
Then Click on Ok
Uncheck : Expand tabs to space.
Click on : Apply
Click On : Ok
If you want set project specific then :
Select : Use project specific options.
Uncheck : Expand tabs to space.
You can also select Language (PHP)
Then Click on Ok
Is there a way to hide the text limit line in netbeans 6.5?
In NetBeans 6.9, setting Right Margin to 0 effectively hides the text limit line.
Set the value in Preferences > Editor > Formatting > All Languages > Right Margin.
(Mac OS X 10.6.4, NetBeans 6.9)
line is not moving to 200 column, but you can hide it setting its color to same as the background
You can set it to 0. So It will not be visible.
Are you talking about the line running thru the right side, by default at the 80 column point? That is Options -> Editor -> Indentation -> Right margin. I have it set at 200 columns which pushes it off the right side of the screen.
Hi~ I found out how to hide "Text limit line" :)
Tools -> Options -> Export(Popup Win) -> Browse.. (Select target "ccc.zip" file)
Select Options for Export : Check at "Editor" -> OK
Edit xml file "\Editors\Preferences\org-netbeans-modules-editor-settings-CustomPreferences.xml" in "ccc.zip" file.
<entry javaType="java.lang.Boolean" name="text-limit-line-visible" xml:space="preserve">
<value><![CDATA[false]]></value></entry>
Tools -> Options -> Import "ccc.zip" file
Done
As for now (October '18) in NetBeans 8.2 + 9 you can hide the text limit line or actually change its color by going to Options -> Fonts & Colors -> Highlighting -> Text Limit Line -> Foreground
Remember to go to tools, options, fonts & colors, highlighting tab, text limit line selected before exporting ccp.zip....
There is an easy way to disable the warning generated by NetBeans for number of lines.
Goto Tools > Options > Editor > Hints
Find the checkbox Too Many Lines > un-check the checkbox
and click Apply.
Enjoy :)
Have you tried to see if your project properties have formatting that overwrites the global properties?
See below:
https://bz.apache.org/netbeans/show_bug.cgi?id=223329