Foreword
I'm using the "indent with tabs, align with spaces" ideology for indentation. This means that each line in a file can be prefixed with an arbitrary amount of tabs and spaces (as opposed to "only spaces" or "tabs when possible, then 0 ≤ x < tabstop
spaces"). For example:
<--># use OLS (ordinary least squares) to find initial guesses
<-->if prefit or initial is None:
<--><-->beta, cov = sp_opt.curve_fit(model,
<--><-->.............................xdata = x,
<--><-->.............................ydata = y,
<--><-->.............................sigma = yerr,
<--><-->.............................absolute_sigma = True,
<--><-->.............................maxfev = int(1e6),
<--><-->.............................p0 = initial)
Here, a <-->
represents a tab character and .
represents a whitespace.
To work in this mode, I have noexpandtab
set in my vimrc. Hence this question on Vim SE is not relevant for me.
Question
When I shift such a line left or right using <<
or >>
Vim operations, Vim replaces (almost) all existing spaces with tabs. How to avoid this?
I want Vim to only do exactly what's said — i. e. insert or remove a single tab character at position 0 of the line.
vim -Nu NONE
. What version of Vim are you using?vim -N -u NONE
.gI<tab>
and unindent with0x
.>
and<
respectively, replacing default indent/unindent actions? If possible, then please turn this into an answer.