Solution in my case
I commented out the following line, and everything went on fine. No further weird corrections was made to the comments.
set smartindent
Other info of my Vim:
For the sake of indentation, here goes the settings:
filetype plugin on
filetype indent on
set autoindent
Also, it has been verified that python-mode
is not at fault. With the python-mode
or without, set smartindent
keeps getting me the problem.
Tentative conclusion:
set smartindent
is not working well, probably, with my folding method specified as follows. Such setting is placed in C:/vim/vimfiles/ftplugin/python.vim
setlocal formatoptions=crnqj
Here goes the correspondence of the characters used, yet none of which seems to be a trouble.
c
: Auto-wrap comments using textwidth, inserting the current comment leader automatically.
r
: Automatically insert the current comment leader after hitting <Enter>
in Insert mode.
n
: When formatting text, recognize numbered lists. This actually uses
the 'formatlistpat' option, thus any kind of list can be used. The
indent of the text after the number is used for the next line. The
default is to find a number, optionally followed by '.', ':', ')',
']' or '}'. Note that 'autoindent' must be set too. Doesn't work
well together with "2".
Example:
1. the first item
wraps
2. the second item
q
: Allow formatting of comments with "gq".
Note that formatting will not change blank lines or lines containing
only the comment leader. A new paragraph starts after such a line,
or when the comment leader changes.
j
: Where it makes sense, remove a comment leader when joining lines.
Reference to a better framed + answered solution
In short, what I observed when editing a Python script is not unique to the "Python filetype" alone. It has to do with the symbol #
, aka "hash".
set smartindent
? I no longer have the problem as described above after simply removing such setting. – Presidentelect:verbose set smartindent
. And if you can disable it for filetype=python withautocmd FileType python setlocal nosmartindent
– Karren