How to replace all tab characters in a file by sequences of white-spaces in intellij?
Asked Answered
T

2

82

Given a file in my project, I want to be able to replace all of the tab characters in the file with white spaces. Is there any way to do this in intellij?

Trumpery answered 12/9, 2014 at 20:43 Comment(0)
B
118

Go to Edit | Convert Indents , and then choose To Spaces or To Tabs respectively. It's in the documentation: Changing identation

Brocky answered 12/9, 2014 at 22:35 Comment(2)
Do you think it's possible to replace tabs with spaces in all files of a project? When I close all my files, the options To Spaces and To Tabs become inactiveHeadrick
Note that this only converts the tabs at the start of a line. Tabs in the middle of a line (between other text) are not touched.Vip
F
62

Replace only tabs used for indentation

  • Ctrl + Shift + A
  • type "To Spaces" > Enter

    To Spaces

Replace all tabs

  • Ctrl + R
  • check Regex
  • Enter \t and spaces
  • Replace all

    Replace tab with 4 spaces

Filbert answered 23/11, 2017 at 23:15 Comment(3)
Note that your search and replace (ctrl-r) will always convert a tab to a fixed number of spaces. It does not do a tabulation where you can line things up from one line to the next by using a tab. The indention trick, however, does indeed line things up.Samalla
Replace Ctrl with Cmd for Mac and works on IntelliJ 2018.3Prothesis
It seems clion is lacking in this area a bit. While it's true that using a regex conversion doesn't keep things aligned properly, it appears to be the ONLY way to ensure there are no tabs left in the file.Anywheres

© 2022 - 2024 — McMap. All rights reserved.