Whenever I want to add a comment to an indented line in vim, I hit Shift–o (open a new row above the current, switch to insert mode) and start typing a Python comment (using #). That hash is then magically moved to the start of the line (no indentation) and I have to click tab a few times.
Anyone know how to work around it?
I suppose you have
set smartindentin your .vimrcSee
:h smartindentI believe you don’t need smartindenting while coding python. So just remove it from your settings or add the following to your .vimrc: