I recently upgraded my Cygwin from a 2015 installation (5 years ago) to the current "2020" version. Gvim now automatically indents by shiftwidth
columns when I press return after a curly brace {
on a line by itself. From an initial web search, I think this might be related to the cindent
option, so I issued the command set nocindent
. The behaviour still persists. Can someone suggest what help page to look at next?
Background: I've been using autoindent for years, but that only matches the indentation of a new line to the indentation of the preceding line, which is what I want. What I'm trying to disable is indentation that is shiftwidth
more than in the preceding line. I am using the same vimrc
file as before the 2020 upgrade of Cygwin.
Here are some key options in my vim session:
indentexpr=GetTeXIndent()
tabstop=3
shiftwidth=3
nocindent
nosmartindent
filetype=tex
Here is a minimum working example (MWE) file test.tex
that exhibits my problem:
% test.tex
%---------
% 1 2
%234567890123456789012345 <-- Physical character column number
navigation and direct manipulation of the data.\footnote
{%
I position my cursor on the {
in column 7 and, in normal mode, press S
or C
to enter insert mode (and overwrite the text). I then enter {%<CR>
, which creates a new line and positions the insertion point on column 10.
Even as I was typing the preceding paragraph and this paragraph, whenever I press <CR>
to start a new line following a line containing the {
character, the insertion point gets indented to column 4 instead of being positioned on column 1. (Yes, all of this text was composed in the file test.tex
). The :map
command shows that the key {
is not mapped to anything.
For those who have tried the MWE, even if you don't know the answer, it would be helpful in identifying the cause of the problem to know whether you get the same behaviour.
New info
The unwanted extra indentation only afflicts a text file if the file name extension is *.tex
, not if it is *.txt
. It seems that I need to delve into how syntax-dependent behaviour controlled by the file type. I peeked into /usr/share/vim/vim81/syntax/tex.vim
, but I think that deciphering it will be a long-term endeavour.
:set indentexpr?
say? How about:set smartindent?
? And finally:set ft?
? Please edit your question with the answers to these.vimrc
file with the exception of mapping<C-2>
through<C-12>
to different font setting commands, since different fonts are installed in the 2020 Cygwin installation of X-windows.{
in the preceding line is in the middle of the line and in quotes.