Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set tabstop doesn't works #14774

Closed
palandovalex opened this issue Jun 11, 2021 · 6 comments
Closed

set tabstop doesn't works #14774

palandovalex opened this issue Jun 11, 2021 · 6 comments
Labels
closed:question issues that are closed as usage questions defaults issues or PRs involving changing the defaults

Comments

@palandovalex
Copy link

palandovalex commented Jun 11, 2021

  • nvim --version: v0.4.3
  • Operating system/version: linux mint 20.1
  • Terminal name/version: terminator 1.91

in my .config/nvim/init.vim. i add:


set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath=&runtimepath
source ~/.vimrc

So, other parametrs from .vimrc works correctly.

But... I set in .vimrc parametrs:

 set expandtab                               
 set tabstop=2

In vim(Vi IMproved 8.1) this works correctly.

But in nvim - this doesn't work.

Actual behaviour

tab add 8 spaces

Expected behaviour

tab should add 2 spaces

@palandovalex palandovalex added the bug issues reporting wrong behavior label Jun 11, 2021
@clason
Copy link
Member

clason commented Jun 11, 2021

Neovim doesn't read .vimrc at all, it uses .config/nvim/init.vim.

@palandovalex
Copy link
Author

Neovim doesn't read .vimrc at all, it uses .config/nvim/init.vim.

in my .config/nvim/init.vim. i add:

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath=&runtimepath
source ~/.vimrc

So, other parametrs from .vimrc works correctly.

@clason
Copy link
Member

clason commented Jun 11, 2021

Does it work if you set it in your init.vim directly? Can you reproduce it on the latest nightly?

@chrisbra
Copy link
Contributor

Note, that tabstop is a buffer-local option, that means it can (and probably will) be overridden by filetype plugins. Meaning, it matters in which file you check the value of the tabstop option. Check :verbose set ts?

@matu3ba
Copy link

matu3ba commented Jun 25, 2021

@chrisbra This lua code does not work. I never understood softtabstop and in treesitter they set it to 0 for tests, so I copied that.

  vim.bo.expandtab        = true; --use space character on pressing Tab key
  vim.bo.softtabstop      = 0; --Tab and BS: insert+delete number of spaces
  if ( vim.bo.filetype == "cpp" ) then -- something is very broken here
    vim.bo.shiftwidth       = 4; --visual mode >,<-key: number of spaces for indendation
  else
    vim.bo.shiftwidth       = 2;
  end
  if ( vim.bo.filetype == "cpp" ) then -- something is very broken here
    vim.bo.tabstop          = 4; --Tab key: number of spaces for indendation
  else
    vim.bo.tabstop          = 2;
  end

and sets always to 2.
Ie for neovim -u init.lua min.cpp containing that file indentation is not 4, but 2.
min.cpp:

int main() {
    //minimal example file
    int a = 3;
    if (a == 3)
    {//cursor here
    }
}
int main() {
    //minimal example file
    int a = 3;
    if (a == 3)
    {
      //cursor here
    }
}

However having no branching to check the filetype, the code works.
Should I create a new issue for this?

@gpanders
Copy link
Member

gpanders commented Jul 18, 2021

Take a look at :h 'shiftwidth', :h 'softtabstop', and :h 'smarttab'. In particular, I suspect the reason this works for you in Vim but not Neovim is that Neovim sets 'smarttab' on by default.

In any case, this doesn't appear to be a bug.

@justinmk justinmk added closed:question issues that are closed as usage questions defaults issues or PRs involving changing the defaults and removed bug issues reporting wrong behavior labels Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed:question issues that are closed as usage questions defaults issues or PRs involving changing the defaults
Projects
None yet
Development

No branches or pull requests

6 participants