Most file types I want to have tabs converted to spaces. However not in Markdown. I went to the Markdown specific File type and see only limited ability to customize it. Is there some way to define filetype-specific editing behavior in Intellij?
To toggle between tabs and spaces: On the main menu, choose Edit → Convert Indents, and then choose To Spaces or To Tabs respectively.
Switch between tabsIn the editor, press Ctrl+Tab . Keep pressing Ctrl for the Switcher window to stay open. Use Tab to switch between tabs and other files.
You can use Find Action with ⌘⇧A (macOS), or Ctrl+Shift+A (Windows/Linux), and then type in 'Show virtual space at the bottom of the file'.
If you need to adjust indentation settings, in the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. On the appropriate language page, on the Tabs and Indents tab, specify the appropriate indents options and click OK.
IntelliJ normally allows you to set indentation settings per language in Code style section of the settings. As far as I know Markdown is not included out of the box and support for it must be installed via plugin. But the plugin doesn't seem to enable Code style configuration for Markdown.
So the only solution I can think of is to set tabs as default indentation in General section of Code style settings and then override it to spaces for individual languages (but that may not be necessary because the code style settings for individual languages will have spaces as default).
One downside of this is that if you work with some filetype other than Markdown which is not natively supported in IntelliJ, it will use tabs even though you might want to use spaces for that filetype.
Alternatively you could create feature request for this functionality either in IntelliJ or the Markdown plugin itself.
EditorConfig can do what you want. Just add a file .editorconfig
to the root directory of your IntellJ project. The following .editorconfig
example will set all files by default to use the 4-character-wide tab character as the indentation, and then a list of other files (and everything in the directory dir2
) to use 2 spaces as the indentation.
#top-most EditorConfig file
root = true
[*]
indent_style = tab
indent_size = 4
[{File1.ext,dir1/file2.ext,dir2/*}]
indent_style = space
indent_size = 2
The file matching format is pretty versatile.
IntelliJ IDEA (and some other JetBrain products) should have this installed by default with no need for a plugin. Others may need a plugin.
I would personally recommend adding these other configs for general compatibility and cleanliness
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
I used it as a workaround, Editor->Code Style->Other File Types
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With