Search code examples
sublimetext3sublimetext

Sublime text 3 misinterpreting indentation when code is pasted


Love Sublime text, though I have come across an issue which seems to be an inconsistent issue when copying code. I used tab for indentation, and when I need to copy over code, it seems to attempt to interpret the tabs as spaces, but results in sending the indentation wonky.

I know you can go into settings, so I did, and change the values for properties such as tab_size, translate_tabs_to_spaces, but nothing seems to prevent it from happening. Instead of being 4 spaces for indentation, the lines are only one space, and when I hit tab it moves it one space.

Question

How do I force Sublime to only use tab for indentation which is currently set to 4 spaces everytime I create a new document?


Solution

  • You don't tell us how you are pasting the code so I am assuming you are doing a simple paste rather than the Sublime Text way with Shift :

    Sublime’s Paste and Indent command fixes this by automatically adjusting the indentation of your pasted code to match the surrounding lines.

    This command is bound to Ctrl+Shift+V on Windows and Linux or Shift+Cmd+V on Mac. Give it a try—it’s magical.