search

Home  >  Q&A  >  body text

How to set automatic indentation of comment lines starting with # in GVIM

The question is simple and clear. I have recently been learning how to use GVIM and encountered some problems with automatic indentation. Generally speaking, GVIM will automatically indent most of my code for me, but when I start a new line and then enter # and the following comments, the line will always start from the beginning automatically. Instead of automatically indenting and aligning like other lines of code. Have you ever encountered similar problems? How to solve it? Thanks.

P.S. My vimrc part is as follows:

set softtabstop=4
set shiftwidth=4
set tabstop=4
set expandtab
黄舟黄舟2748 days ago542

reply all(1)I'll reply

  • 某草草

    某草草2017-05-16 16:38:25

    For Python, a simple and crude method is:

    set nocindent
    set nosmartindent
    set autoindent
    

    You can add the above commands to autocommand or ftplugin

    reply
    0
  • Cancelreply