Eclipse 多行缩进使用制表符而不是空格 (pydev)
当我在 Eclipse 中突出显示一段文本并按 TAB 时,它会在每行的开头插入一个制表符。我希望它插入 4 个空格。
我需要对具有自定义扩展名的文件执行此操作: *.shpaml
我安装了 PyDev。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我正在考虑使用 PyDev 编辑器打开 *.shpaml...
有 2 个与之相关的首选项:
在窗口中 > >偏好> PyDev >编辑器,您可以选择“输入时用空格替换制表符吗?”并在同一页面中“当文件包含制表符时假定制表符间距?”。
因此,可能您都已选中,并且您的 *.shpaml 中有一些制表符,这使得 PyDev 可以使用制表符...如果您取消选中“当文件包含制表符时假定制表符间距?”,它应该做你想做的事。
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、窗口、首选项、常规、编辑器、文本编辑器、
勾选“输入时用空格替换制表符”
这是旧 Eclipse 版本中的“为制表符插入空格”)
新名称更清楚地表明该选项仅适用于键入而不适用于使用 Tab 键缩进。
在其他编辑器中打开文件可能仍会导致出现选项卡。
从文件中删除所有现有选项卡也是明智之举。
打开每个文件,然后从查找-替换功能 (Ctrl-F) 中勾选“正则表达式”,然后查找:\t 并替换为 4 个空格。
但是,制表符仍将通过左移和多行制表符键插入。
两个选项是使用上述方法之一将制表符转换回空格,或者不使用制表符或右移,右键单击所选块并选择“快速修复”选项之一,例如用if、while 或 try - 如果在上下文中合适的话。
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.
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.
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.
此外,在确保模块符合 PEP8 规范时,我遇到了同样的问题,并且必须对已经编写的代码执行此操作,在这种情况下,上述方法不起作用。
转到窗口>偏好?皮德夫?文本编辑器单击显示空白字符。突出显示一个选项卡并单击 cntrl f。将制表符空格粘贴到查找框中,将四个空格粘贴到替换框中。点击全部替换。
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.