Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I enter a literal <TAB> character in IntelliJ/IDEA/PyCharm?

My configuration indents with four spaces, and I want to keep that. Occasionally (e.g. in a Makefile) I want to input a literal TAB character.

How can I force the IntelliJ-IDEs to input a tab or space, when it would not do so when I hit tab or space in that instance?

like image 429
Robert Siemer Avatar asked Aug 04 '16 13:08

Robert Siemer


People also ask

How do I get special characters in IntelliJ?

How to show tabs and white space characters in IDEA? To enable this feature in IntelliJ, you must open the Settings dialog ( Ctrl+Alt+S ) and navigate to the Editor | General | Appearance tab. In this tab you need to enable the Show whitespace option.

How do I add a tab in PyCharm?

To reopen the closed tab, right-click any tab, and from the context menu, select Reopen Closed Tab. To open a new tab at the end of the already opened one, select the Open new tabs at the end in the tab settings.

How do I change the tab space in PyCharm?

ctrl + shift + A => open pop window to select options, select to spaces to convert all tabs as space, or to tab to convert all spaces as tab.


1 Answers

You seem to be asking two questions here:

1. How do I force IntelliJ IDE to input a tab, when it would not do so when I hit tab?

and

2. How do I force IntelliJ IDE to input a space, when it would not do so when I hit space?

I don't understand how the second case can arise. However, I have provided a solution to it as well.

Case 1. Insert a tab character when an IntelliJ IDE wants to replace it with spaces due to configuration

Solution

Use search and replace.

Details

  1. Place the cursor where you want the tab to be
  2. Press the X key
  3. Select the X you just typed
  4. From the main menu, choose Edit | Find | Replace to bring up the search and replace pane
  5. Make sure there is an X in the search field
  6. Enter \t in the replace field
  7. Be sure the option Regex is checked
  8. Be sure the option In Selection is checked
  9. Click the Replace button

Case 2. Insert a space character when an IntelliJ IDE won't just let you type one (???)

Solution

Use search and replace.

Details

  1. Place the cursor where you want the space to be
  2. Press the X key
  3. Select the X you just typed
  4. From the main menu, choose Edit | Find | Replace to bring up the search and replace pane
  5. Make sure there is an X in the search field
  6. Enter a single space into the replace field
  7. Be sure the option In Selection is checked
  8. Click the Replace button
like image 163
Arno Dverjging Avatar answered Oct 24 '22 22:10

Arno Dverjging