How to Set Automatic Indentation of Annotation Lines Beginning with #

  question, vim

The question is simple and clear. Recently studying the use of GVIM, inAuto indentSome problems have been encountered. Generally speaking, GVIM will automatically indent most of my code for me, but when I start a new line, then type#As well as the following comments, this line will always automatically start from the beginning, instead of indenting and aligning like other lines of code. Have you encountered any similar problems? How should it be solved? Thank you

P.s. my vimrc section reads as follows:

set softtabstop=4
 set shiftwidth=4
 set tabstop=4
 set expandtab

For Python, one simple and crude way is:

set nocindent
 set nosmartindent
 set autoindent

You can add the above command to autocommand or ftplugin