4

Here is part of my vim setting:

set tabstop=4
set sts=4
set expandtab
set softtabstop=4
set shiftwidth=4

When I edit a file in /mtp/test, type print('ok') in the first line, and type 1> in ex mode, I get the normal result, character p is in the 5th column. > moves the whole line to the right by 4 whitespaces.

enter image description here Now I edit a file in another directory /home/debian/mydoc/source/shell/,

sudo -E vim  /home/debian/mydoc/source/shell/test.py
print("ok")

When I type 1> in ex mode, I get the strange output:
enter image description here

Character p is in the 4 column. > moves the whole line to the right by 3 whitespaces!

It shocks me! I find that for all file which ended with .rst the value shiftwidth is 3, how to search which plugin set it with 3?

guntbert
  • 1,245
  • 1
  • 13
  • 27
showkey
  • 1,130
  • 2
  • 11
  • 30
  • 1
    Have you checked that the value of your settings is the same for both files? I see that you edit a file without filetype and one python file maybe a plugin changes the values (you can check with :set shiftwidth? Also your second command uses sudo -E, just to be sure the problem doesn't come from there have you reproduced the issue without sudo? – statox Feb 17 '21 at 11:26
  • It is no difference with or without sudo,i find that for all file which ended with .rst the value shiftwidth is 3,how to search which plugin set it with 3? – showkey Feb 17 '21 at 12:03
  • 3
    :verbose set shiftwidth should give you the answer you're looking for – statox Feb 17 '21 at 12:04
  • Last set from /usr/share/vim/vim81/ftplugin/rst.vim line 34 – showkey Feb 17 '21 at 12:16
  • See my answer :) – statox Feb 17 '21 at 14:00

1 Answers1

4

As debugged in the comments:

The ftplugin for rst files sets shiftwidth to a value you don't like, so you will need to override it. To do so create the following file:

$HOME/.vim/after/ftplugin/rst.vim

And in it add the following line:

set shiftwidth=4

And you should be good to go. Have a read at :h ftplugin if you are not familiar with ftplugins.

statox
  • 49,782
  • 19
  • 148
  • 225