1

For some reasons when I'm editing my ~/.config/nvim/init.vim, it adds 8 spaces even though I set set tabstop=4 on the file. Actually, :verbose set tabstop returns 4, so it should be 4 spaces.

I already read the questions here and here, and strangely, in Python I have no problem on adding 4 spaces.

What is causing the problem? How can I investigate the problem further and fix it up?

11
  • It shouldn't be inserting 4 spaces it should be adding a Tab. That is, unless you have some other settings with non-default values...particularaly 'expandtabs'. And what do you have for 'softtabstop', 'shiftwidth', 'cpoptions' while we're at it? This is only for *.vim files? Only when you simply hit Tab in Insert mode or other circumstances (e.g. autoindent scenarios)?
    – B Layer
    Commented Jul 8, 2018 at 22:27
  • Doesn't your init.vim file have a mode line? It's a comment in the file itself, by default in the 5 first or last lines which begin with " vim:" and allow to override some options like tabstop...
    – fievel
    Commented Jul 8, 2018 at 22:35
  • @fievel That's equivalent to :setlocal and would show up as the value returned by :set tabstop ... OP said that returns 4.
    – B Layer
    Commented Jul 8, 2018 at 22:44
  • Oh, and add your value for 'smarttab', too @Blaszard.
    – B Layer
    Commented Jul 8, 2018 at 22:52
  • @BLayer softtabstop is 4, and I found that the shiftwidth is set to 8. Setting it to 4 solved the problem, thanks.
    – Blaszard
    Commented Jul 8, 2018 at 23:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.