I was editing a fairly extensive ant xml build file file and tried to add in an extra tab where I thought appropriate. As it happens, the tab shouldn't have been there (if we were following some "rules" on What Looks Pretty In XML).
And as it happened, eclipse refused to let me put the tab there. I tried a few times, and sometimes it would "allow" one extra tab, but v. often it would either
ignore the tab
remove a tab
I know that what eclipse is doing is "right", (in some byzantine sense, because this isn't python, it is an ant xml build file, so the only way it is "right" is from an aesthetics point of view) but I think it is "stupid".
How can i disable this "feature" in eclipse?
I assume you mean the tabulator key (as opposed to the sub-windows, that are also called tabs).
Look up your editor preferences. Things that might help are the settings "insert spaces for tabs", "displayed tab width" and "smart caret positioning at line start and end".
If this doesn't help, try to avoid the XML editor by not opening with double-click, but using "Open With .." -> "Text Editor"
Related
I'm using JBehave and its companion plugin with Eclipse, which is fine, but there is something that makes me mad, it DO NOT react when I hit Ctrl+F, which I expect to open the search dialog box.
I crawled a bit on the internet but except some messages on the mail archive (https://www.mail-archive.com/user#jbehave.codehaus.org/msg02382.html) stating the same problem, I did not found any answer until then.
I finally found a way to circumvent the problem, and I feel it may be of some use to other people so here it is :
I opened the Preferences > Keys and copied the "Find and replace text".
On the copy, I chose to set "When" to "JBehave Story Editor", and "Binding" to "Ctrl+F"... and surprise ! It then showed me that it conflicted with a "Format Table" command in this particular "When" context.
Curiously, this mapping is not shown when I enter "Ctrl+F" in the filter text area...
Actually, the whole "JBehave Story Editor" When context seems totally invisible in the Keys list.
Anyway, I somehow fixed the problem by setting "Ctrl+Shift+F" to the duplicated "Find and Replace" with When set to "JBehave Story Editor", which works fine.
By the way, I discovered that when selecting a JBehave table and hitting Ctrl+F, it actually pretty-print it with appropriate padding in the cells to make the column align nicely :)
UPDATE
Actually I found how make "JBehave Story Editor" shortcuts appear in the list :
In Preferences > Keys, hit Filters... and uncheck "Filter uncategorized commands".
Then "Format Table" appears, and it is then possible to remap it to Ctrl+Shift+F for example.
The "Find and replace text" duplication is no more needed :)
I downloaded some code from the Internet, and the four-space indentation is bugging the crap out of me. I tried to do a find and replace for "<4 spaces>" and replace it with "\t", but that just replaced all sets of spaces with the string "\t". How would I put a tab in the "replace" box?
Open Window->Preferences from menu bar.
Select Text Editors from tree menu.
Uncheck Insert spaces for tabs.
After that, run Format menu from context menu and save the file:
I figured it out. I just check the box that says "use regular expressions", then use \t.
In answer to the second half of your question:
The reason why people like spaces more than tabs is consistency. If you have your editor set to show tabs as 4 spaces wide, and I have my editor set to show tabs as 8 spaces wide, the code we're writing will look different to each of us. That's okay until our mutual coworker forgets that we're using tabs and starts spacing his lines using 4 spaces. Now his code looks fine to you, but all the indentation is off to me.
Also, what happens when our work decides that lines should be 80 characters long, or 120 characters long? You'll happily code with 4 space tabs, and when it gets to my editor, I suddenly see some of your lines as too long.
Generally, it doesn't matter whether you use spaces or tabs, as long as you (and every person who works on your code) agrees on which to use, and how wide a tab character is.
I use 4 spaces everywhere, because it looks the same on every editor, every repository, when cated, and everywhere else.
Kouhei response is in the right track, but you'll need to change the options of the Java formatter if you want the auto formatter to use spaces (in the preferences, look for Java -> Code Style -> Formatter, create a new style from one of the existing one, and choose "always use spaces"). Then, Ctrl + Shift + F will remove the tabs and insert spaces.
To resolve the issue of tab with space in the Eclipse editor:
Menu Window --> Preferences --> Java --> Code style --> Formatter
Click on configure project specific settings.
Choose the project
Check Enable project-specific settings
Click on New
Mention your profile name --> click OK.
The profile page will be popped up
Choose Space only under tab policy label of the indentation tab.
Click apply and the OK.
Use Ctrl + Shift + F to format a Java class which will replace tab with space.
Eclipse Helios for C++ developers
Instead of changing the default text editor, change the Code Style/Edit -> see pictures
I am using Adobe's ColdFusion Builder, an Eclipse-based IDE built on top of Aptana.
All of a sudden, I am getting a type of whitespace marker showing in my Eclipse Editor. I must have accidentally hit a key combination.
Here is a screen dump.
I have already tried "General > Editors > Text Editors > Show whitespace characters" and it is not this. I already have show whitespace characters turned off. If I turn it on, then the Whitespace Characters display over the top of what I am already seeing.
Can anyone tell me how this can be turned off? Most annoying.
Many Thanks
It's under Preferences -> General -> Editors -> Text Editors
Just uncheck 'Show Whitespace Characters':
Did you try Restarting Eclipse? If that didn't work, you might try this http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka11640.html which explains which file to delete to force eclipse to revert to use default settings.
I have done this several times by accidentally hitting some keystrokes.
If you go to Windows/Preferences/General/Keys you will see all the keyboard shortcuts you have.
Mine is set to Control + .
(that's a period by the way) I had to place my cursor inside the document and do it a couple of times to make it work because there is also a keyboard shortcut for Control +
On a Mac it is Cmd +.
Hope that helps.
I find Eclipse's (Eclipse 3.7, Indigo, running under Mac OS X 10.6.8) Find/Replace floating dialog box to be very annoying. Part of the time it ends up obscuring the search results. Is there any way to have Eclipse move the Find/Replace somewhere else? I'd like it to be a pop-up view, as I often do with the Console, Servers, Outline, and other views. However, if it could be incorporated into the view which it's searching, that would be great, too.
Eclipse's Find / Replace dialog is a dialog, not a view, so you can't drag and drop it to one of the view areas.
Here's a Eclipse search plugin that might work for you. Scroll all the way to the bottom of the page to get the Software Update link.
Worst case, you could write your own Eclipse plug-in that creates a view that does a Find / Replace.
TL;DR
Find/replace cannot be used as a view. Here are two ways to find text without obstructing the search:
Use incremental search (CTRL+J)
Use the quick search plugin (CTRL+SHIFT+L)
Pros and cons
Both approaches behave differently from the traditional find/replace and may require some getting used to.
Approach 1.
It works out of the box, no need to install a plugin, but it (currently) does not support pasting nor searching for the current selection (but there is CTRL+K for the latter). You can use UP and DOWN or repeat CTRL+J or CTRL+SHIFT+J to jump between matches.
Approach 2.
This still opens a dialog, but one which integrates the search results rather than obscuring them. I suggest resizing it to have a good preview size.
The default shortcut shadows the "Show Key Assist" original, but this can be changed. It is an extra install and AFAIK only supports case sensitive searches, but it supports searching for the selection and pasting.
It shows matches across files, starting with the top open editor (if you have more than one visible, e.g. side by side, it sometimes does not start with the one you were last on). You can move between matches with UP and DOWN and hit enter to go back to the editor on the selected match.
NOTE
I suppose on OSX you can replace CTRL with CMD in keyboard shortcuts above to achieve the same, but I could not test it. The shortcuts can be customized in Preferences->General->Keys
Here are the ways the Eclipse documentation states you can navigate the Content Assist list:
You can use the mouse or the keyboard
(Up Arrow, Down Arrow, Page Up, Page
Down, Home, End, Enter) to navigate
and select lines in the list.
But all of the options require you to move your hands significantly away from their natural place on the keyboard!
Are there any other, quicker ways I can navigate this list? Something like tab, or the j/k from vi?
This is a great feature, and you can implement it like so: bind movement keys in Eclipse's key binder and then use them in the content assist menu!
Preferences/General/Keys
Line Down: Bind to Ctrl+K
Line up: Bind to Ctrl+I
(both when 'Editing Java Source')
and then try moving with Ctrl-K/I when the content assist pops up!
In Kepler, as jed mentions in the comments, select "when editing text" instead and it should work.
If you try to fill in the content manually, Eclipse will move.
The search is quite advanced, e.g. "ArL" can match ArrayList, etc., so if you know what you are looking for, instead of navigation you could use search.
This is certainly not a solution for everyone, but if you switch to the Emacs keyboard layout you can just use the key bindings for the "previous line" and "next line" commands, e.g., Ctrl-P and Ctrl-N.