Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

So after quite a lot of searching and frustration I'm here to ask how to do one of the most basic (or so I thought) things in a modern text editor. I want to set a different indentation for different files types. I almost all the time edit javascript+HTML/XML+python together, and cannot have a fixed 4-spaces or 2-spaces indentation.

I tried setting the indentation mode for different files. However, I cannot find a way to change the number of spaces to indent for each mode. In Settings->Configure Kate->Editing->Indentation, I can set the Default Indentation Mode and select the number of spaces to indent. But there's no way to change the number of spaces to indent for each mode.

Temporary solution:

add,

<!-- kate: indent-width 2; -->

at the beginning of every XML file. Which is quite annoying.


Obviously I want to know if there's a easier way to do it, but if there's no way to do it from the UI, I would love if someone can help me cook up a solution.

I found this bug report (filed 5years ago), where the person mentions something like

The current workaround is to type "kate: indent-mode " into Variables under filetype properties.

I don't know where to find this filetype properties :/ or even if it exists.

share|improve this question
1  
Settings → Configure Kate... → Editor Component → Open/Save → Modes & Filetypes –  ninjalj Oct 30 '13 at 15:21
    
see, you can select the indentation **mode** there, but the problem is no way to change the number of spaces to indent for each mode. –  xcorat Oct 30 '13 at 16:18
2  
You should be able to select Markup/XML as Filetype: and enter kate: indent-width 2; into Variables:. –  ninjalj Oct 30 '13 at 17:01
    
OH varibles: GOD DAMN IT I DIDN'T SEE :)))) thx. –  xcorat Oct 30 '13 at 17:17

1 Answer 1

Being a Kate developer myself, the answer is indeed as discussed in the comments. Each mode / filetype can be configured individually through document variables in Settings → Configure Kate → Editor Component → Open/Save → Modes & Filetypes. Therein, select your desired filetype, e.g. Scripts/Python. Then select your preferred indentation mode. To set the indent width, you can click on the little tool-button next to the Variables line edit, which will popup a list with all document variables available. Set indent-width to e.g. 4 and close the popup. The Variables line edit then contains the string kate: indent-width 4:, which is exactly the same string that you can also embedd directly into your document, if wanted.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.