Search code examples
rubymine

Manually insert a tab character in RubyMine


I am using RubyMine 2017.1.5 and it is working exactly as one would generally expect. Right now when I press the Tab key it inserts spaces based on my preferences.

However, I need to do something unique. My application generates a my_file.tab file that uses \t as the delimiter. One of our specs compares the generated output to an example file. I need to make a change to this example file by inserting tabs, but RubyMine automatically inserts spaces instead.

Reminder: I do generally want RubyMine to convert tabs to spaces, but I need a way to insert tabs when needed.

Is there a way to manually insert an actual tab character in RubyMine?


Solution

  • The recommended way is to set tab input for any file other than code source. Preferences -> Editor -> Code Style -> Other File Types -> Use tab character. This will allow you input tab character in normal text files while keep code editor soft tab.

    Also there is an advanced alternative to do this. All jetbrains IDE has enabled a EditorConfig plugin to support EditorConfig style configurations for any type of file. Check the official documents here.

    Generally, you need to create a .editorconfig file (normal .ini style) under the project root dir , and write it with your file type config:

    [*.tab]
    indent_style = tab
    # and set indent size if you like:
    # indent_size = 4
    

    (May need restarting IDE) All *.tab files will follow this coding style (insert the real tab character) now.