When I highlight a block of text in Eclipse, and press TAB, it inserts a tab at the head of each line. I want it to insert 4 spaces instead.
I need to do this on a files with a custom extension: *.shpaml
I have PyDev installed.
When I highlight a block of text in Eclipse, and press TAB, it inserts a tab at the head of each line. I want it to insert 4 spaces instead.
I need to do this on a files with a custom extension: *.shpaml
I have PyDev installed.
I'm considering that *.shpaml is opened with the PyDev editor...
There are 2 preferences related to that:
In window > preferences > PyDev > Editor, you can choose 'replace tabs with spaces when typing?' and in that same page 'assume tab spacing when file contains tabs?'.
So, probably you have both checked and your *.shpaml has some tab in it, which makes PyDev work with tabs... if you uncheck the 'assume tab spacing when file contains tabs?', it should do what you want.
You should be able to set "spaces instead of tabs" here:
Eclipse, Window, Preferences, General, Editors, Text Editors,
Insert spaces for tabs=Y
Use the settings: Eclipse, Window, Preferences, General, Editors, Text Editors, Tick 'Replace tabs with spaces when typing' This was 'Insert spaces for tabs' in older Eclipse versions)
The new name makes it clearer that this option only applies to typing and not indenting with the tab key.
Also untick setting 'Assume tab spacing when files contain tabs'
Otherwise Eclipse will still fall vack to tab spacing when files contain tabs'.
Opening files in other editors may still lead to tabs.
It is also wise to remove all the existing tabs from your file. Open each file, then from the Find-Replace Function (Ctrl-F), tick 'Regular expressions' then Find: \t and Replace by 4 spaces.
Or Source -> 'Convert tabs to space-tabs'
However, tabs will still be inserted by the Shift Left and Multi-line tab key. Two options are to convert the tabs back to spaces using one of the above methods or instead of using tab or shift-right, right-click on the selected block and choose one of the 'Quick fix' options such as surround the block with an if, while or try - if that is appropriate in the context.
untick setting 'Assume tab spacing when files contain tabs'
Thanks! –
Sedimentary Additionally, I had this same problem when making sure a module was PEP8 compliant and had to do this for code that was already written in which case the method above does not work.
Go to windows > preferences ? PyDev ? text editor click show whitespace characters. Highlight a tab and click cntrl f. Paste the tab whitespace into find box and four spaces into the replace with box. Hit replace all.
© 2022 - 2024 — McMap. All rights reserved.