I have an unfortunate problem with Eclipse that only happens in existing Python files with tabs somewhere in them. It doesn't happen in empty files or non .py files.
Basically, if I try to copy and then past more than 3 spaces I end up with tabs for every X spaces, X being the number of characters per space setup for the editor. In my case this is 4, so I end up with the following:
Copy and paste 1 space: " " (one space)
Copy and paste 3 spaces: " " (three spaces)
Copy and paste 6 spaces: "\t " (one tab, two spaces)
Copy and paste 9 spaces: "\t\t " (two tabs, one space)
Copy and paste 12 spaces: "\t\t\t" (three tabs)
For the life of me I can't figure out why this is happening or how to turn it off. It's really frustrating to have to keep manually editing each line I paste instead of getting exactly what I copied in the first place.
Does anyone know what setting this is, or if it's just a bug?
EDIT: To be clear I do not want spaces when I hit the tab key, I want the tab characters when I ask for the tab characters. However when I want to paste a space I do not want the characters changed, especially if it's clear I'm between single or double quotes and just trying to write text as is.
This happens because at:
org.python.pydev.editor.autoedit.AbstractIndentPrefs.convertToStd(IDocument, DocumentCommand) it'll do it both ways (either make spaces -> tabs or tabs -> spaces), so, there isn't really an option to let it as it was.
code:
private String convertSpacesToTabs(IDocument document, String text, int offset, String indentString)
throws BadLocationException {
String spaceStr = StringUtils.createSpaceString(getTabWidth());
while (text.startsWith(spaceStr)) {
text = text.replaceAll(spaceStr, "\t");
}
return text;
}
There are 2 possible fixes here:
As PyDev is open source, ideally someone could provide a patch for that (see http://pydev.org/developers.html for getting the code).
Otherwise, you can create a ticket at https://sw-brainwy.rhcloud.com/tracker/PyDev ;)