Eclipse:同时使用制表符和空格进行缩进
Eclipse: use both tabs and spaces for indentation
我正在做的一个项目有如下缩进标准:
- 单个制表符宽度为 4 space 个字符。
- 双制表符宽度是显示为 8 space 秒宽的制表符。
示例:
- 单缩进行以四个 spaces
开头
- 双缩进行以制表符开头
- 三重缩进行以制表符开头,后跟四个 spaces
- 4 倍缩进行以两个制表符开头
- ...等等
在Vim中,必要的配置是通过以下方式实现的:
:set tabstop=8 softtabstop=4 noexpandtab
如何配置 Eclipse 以自动执行此缩进标准?
我不相信 Eclipse CDT 支持这种缩进样式。
Eclipse 是开源的;您可以考虑 contributing a patch 添加对此样式的支持。
Eclipse 没有内置的插件,但看起来插件 Vrapper (Vim) 提供了您正在寻找的东西。
见Vrapper > Documentation > Configuration:
- softtabstop - When using spaces for tabs, set this to the number of spaces inserted for each Tab key press and hitting
Backspace in InsertMode will delete that many spaces as if you had
deleted a tab character.
- tabstop - Used by
i_ctrl-t
, i_ctrl-d
, and :retab
. Determines number of spaces to replace each tab character with when xpandtab
is enabled.
- expandtab/noexpandtab - Used by
i_ctrl-t
, i_ctrl-d
, and :retab
. Determines whether :retab
should replace all tabs with spaces (true) or spaces with tabs (false). Also determines whether i_ctrl-t
and i_ctrl-d
will replace tabstop
spaces with a tab.
Eclipse 本身就支持这个。
我的eclipse版本:
结果(见图片评论):
第 1 步:
第 2 步:
第 3 步:
第四步(最重要的一步):
我正在做的一个项目有如下缩进标准:
- 单个制表符宽度为 4 space 个字符。
- 双制表符宽度是显示为 8 space 秒宽的制表符。
示例:
- 单缩进行以四个 spaces 开头
- 双缩进行以制表符开头
- 三重缩进行以制表符开头,后跟四个 spaces
- 4 倍缩进行以两个制表符开头
- ...等等
在Vim中,必要的配置是通过以下方式实现的:
:set tabstop=8 softtabstop=4 noexpandtab
如何配置 Eclipse 以自动执行此缩进标准?
我不相信 Eclipse CDT 支持这种缩进样式。
Eclipse 是开源的;您可以考虑 contributing a patch 添加对此样式的支持。
Eclipse 没有内置的插件,但看起来插件 Vrapper (Vim) 提供了您正在寻找的东西。
见Vrapper > Documentation > Configuration:
- softtabstop - When using spaces for tabs, set this to the number of spaces inserted for each Tab key press and hitting Backspace in InsertMode will delete that many spaces as if you had deleted a tab character.
- tabstop - Used by
i_ctrl-t
,i_ctrl-d
, and:retab
. Determines number of spaces to replace each tab character with whenxpandtab
is enabled.- expandtab/noexpandtab - Used by
i_ctrl-t
,i_ctrl-d
, and:retab
. Determines whether:retab
should replace all tabs with spaces (true) or spaces with tabs (false). Also determines whetheri_ctrl-t
andi_ctrl-d
will replacetabstop
spaces with a tab.
Eclipse 本身就支持这个。
我的eclipse版本:
结果(见图片评论):
第 1 步:
第 2 步:
第 3 步:
第四步(最重要的一步):