For some reason when I create a new line in vim and the first character I enter is "#" (to add a comment in python for example) vim cancels the automatically created tabs and moves the number sign and the cursor to the start of the line. It happens when I use the "o" command from Normal mode and when I press enter in Insert mode.
For example, if I have a function:
def some_function():
a = 1
And I create a new line under "a = 1", vim will automatically indent the new line. But if I enter "#" it will jump back to the start of the line.
Does anybody know what causes this? And more importantly, how do I cancel it?