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?

  • 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
    Jul 8 '18 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
    Jul 8 '18 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
    Jul 8 '18 at 22:44
  • Oh, and add your value for 'smarttab', too @Blaszard.
    – B Layer
    Jul 8 '18 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
    Jul 8 '18 at 23:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.