One way to do it is to use "fake" indentexpr value:
Having this applied to a filetype (or a buffer without filetype) will make == and friends (gg=G, =ip, etc) never change existing indentation.
I had similar problem with a mappings that move lines/selection up and down reindenting after each move (like if a line ends up in an if ...
This is a misuse of = operator.
Actually, Vim has two builtin "formatting" operators, i.e. = and gq (there's also gw that is simply the same as "internal" gq-formatter).
= is supposed for use with programming languages. Of course, it could be set up to do anything you like, but it defaults to C. Does it come as surprise? I don't think so.
Here is one option, first find your file type by typing :set filetype? within your Vim opened file.
Suppose it spits out css, then in your .vimrc file, add the line
autocmd FileType css setlocal indentexpr=
Within your .vimrc file, add the line
autocmd FileType plaintex,tex,context setlocal indentexpr=
autocmd automatically applies the setup when criterion is met
FileType is the criterion to be met (for files of certain type)
plaintex,tex,context are the common filetypes recognized by vim (see Vim documentation)
setlocal indentexpr= sets the required ...
I had this just recently and my solution was different.
My vim setup was:
--- Options ---
background=dark history=200 langnoremap nomodeline ruler scrolloff=5 ttimeout ttyfast wildmenu
display=truncate incsearch nolangremap nrformats=bin,hex scroll=37 ...