I got some files have mixed indentation, is there any way I can automatically convert the indentation in Kate?

7 Answers 7


Try to do Ctrl + A to select all text and then Ctrl + X to cut it and Ctrl + V to paste it back. It will automatically format the indentation accordingly to your settings in Kate configuration.

  • 5
    Not anymore it doesn't Oct 22, 2015 at 11:27
  • I can't get this to work either. I have the setting checked: "Settings" -> "Configure Kate..." -> "Editor Component" -> "Editing" -> "Indentation" -> "Adjust indentation of code pasted from the clipboard". It does not appear to convert tabs to spaces or vice-a-versa when pasting. Jan 5, 2018 at 11:43
  • Works perfectly, converts all tabs, even those which don't have maximum length, to the correct amount of spaces. I do not have the box checked that @StephenOstermiller mentioned. Kate version 3.13.3 Feb 22, 2018 at 12:23
  • 1
    I currently have Kate v 17.04.3. It looks like the 3.x versions are several years old. This functionality must be broken in the newer versions. Feb 22, 2018 at 12:45
  • Works on kate v23. Dec 12, 2023 at 19:07

Select the text you want to modify, then 'Tools > Clean Indentation'.

  • That's sort of an iffy solution. Cleaning the indentation ensures that all your selected text follows the indentation mode you choose. Depending on what mode you chose and why the indentation varies (like what you manually stuck at the beginning of the different lines), the results may be mixed. It may try to at least make all of the indents uniform (not always successful), which may be based on a rule like the least indented line.
    – fixer1234
    Sep 23, 2016 at 17:51
  • This seems to work for me, even in cases of mixed indentation. If I have my preference set to "tabs" with four space width, it will replace all of the following with two tabs: eight spaces), four spaces and a tab, a tab and four spaces, and even really mixed cases like six spaces and a tab (which would render as two tab widths). Jan 5, 2018 at 11:38
  • 2
    Doesn't work for me in case of tabs in between letters, they are not converted to spaces. This is important e.g. for tabs in comments of programming languages. Feb 22, 2018 at 12:21
  • Worked for me in Version 19.08.3. Dec 3, 2019 at 15:58

If you do Tools -> Switch to Command Line (or you hit F7), you can highlight the text in question and type the command "cleanindentation" in the command box.


Select the text you want to modify and run it through 'Tools > Filter Text'. Use command 'expand -t4' (or whatever indentation you want).

  • Also unexpand -t4 to convert those spaces back to tabs instead.
    – Tynach
    Oct 19, 2022 at 5:32

Use key combination CTRL+R to open the replacement dialog window. Now use mouse and mark one tabulator, press CTRL+C and paste it under "Find" section. Under section "Replace" just input four spaces and click "Replace all".

  • 1
    you can enter tabulator as "\t" and switch option "escape sequences" ON, no need to do sorcery with ctrl+C/V ... But this will replace tabulator with fixed amount of spaces provided in the replace dialog, so it will break any indentation previously provided by the tab characters.
    – Ped7g
    Oct 10, 2019 at 19:17

In version 15.12.3, Try to do Ctrl + A to select all text and then select Tools -> Align.


Ctrl+A -> ↹ Tab -> Shift+↹ Tab

Assumes you've changed your Settings -> Editing Options to Indent using Spaces.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .