如何在IntelliJ IDEA中使用制表符进行缩进? [英] How can I use tabs for indentation in IntelliJ IDEA?

查看:463
本文介绍了如何在IntelliJ IDEA中使用制表符进行缩进?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在IntelliJ IDEA 11.0中使用制表符而不是多个空格进行缩进?

How can I use tabs instead of multiple spaces for indentation in IntelliJ IDEA 11.0?

我在代码样式">常规">默认缩进选项"下选中了使用制表符".并且还尝试选中智能标签",但这无济于事.

I have "Use tab character" checked under "Code Style" > "General" > "Default Indent Options". And also tried to have "Smart tabs" checked, but it doesn't help.

文档:

如果选中此复选框,则使用制表符:

If this check box is selected, tab characters are used:

  • 按Tab键
  • 缩进
  • 用于代码重新格式化
  • On pressing the Tab key
  • For indentation
  • For code reformatting

否则,将使用空格代替制表符.

Otherwise, spaces are used instead of tabs.

推荐答案

IntelliJ IDEA 15

仅适用于当前文件

您有以下选择:

IntelliJ IDEA 15

Only for the current file

You have the following options:

  1. Ctrl + Shift + A >编写标签">双击至标签"

  1. Ctrl + Shift + A > write "tabs" > double click on "To Tabs"

如果要将制表符转换为空格,可以编写空格",然后选择至空格".

If you want to convert tabs to spaces, you can write "spaces", then choose "To Spaces".

编辑>转换缩进>到制表符

要将制表符转换为空格,可以从同一位置选择到空格".

To convert tabs to spaces, you can chose "To Spaces" from the same place.

对于所有文件

其他答案中的路径有所改变:

For all files

The paths in the other answers were changed a little:

  • 文件>设置...> 编辑器>代码样式> Java>制表符和缩进>使用制表符
  • 文件>其他设置>默认设置...> 编辑器>代码样式> Java>制表符和缩进>使用制表符
  • 文件>设置...> 编辑器>代码样式>检测并使用现有文件缩进进行编辑
  • 文件>其他设置>默认设置...> 编辑器>代码样式>检测并使用现有文件缩进进行编辑
  • File > Settings... > Editor > Code Style > Java > Tabs and Indents > Use tab character
  • File > Other Settings > Default Settings... > Editor > Code Style > Java > Tabs and Indents > Use tab character
  • File > Settings... > Editor > Code Style > Detect and use existing file indents for editing
  • File > Other Settings > Default Settings... > Editor > Code Style > Detect and use existing file indents for editing

如果您从设置... 其他设置>默认设置... 中选中/取消选中该框,似乎没有关系,因为在一个窗口中进行更改将在另一窗口中可用.

It seems that it doesn't matter if you check/uncheck the box from Settings... or from Other Settings > Default Settings..., because the change from one window will be available in the other window.

以上更改将应用​​于新文件,但是如果您想更改现有文件中标签的空格,则应 format ,方法是按 Ctrl + Alt + L .

The changes above will be applied for the new files, but if you want to change spaces to tabs in an existing file, then you should format the file by pressing Ctrl + Alt + L.

这篇关于如何在IntelliJ IDEA中使用制表符进行缩进?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆