Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm not able to change the tab space from 2 to 4 in NeoVim

Tags:

lua

neovim

I am new to NeoVim. I tried following TJDeVries's tutorial on YouTube and I got NeoVim working with Kickstart.nvim. I wanted to set the Tabspace from the default 2 space to 4 space. I tried doing what The Primeagen in his NeoVim from scratch video and tried doing what he had done. However, it didn't work.

I tried making a separate directory called lua which had indent.lua and linked it to the init.lua file. I had expected it work however it did not. This is what I had typed in the indent.lua file. I know that there is something wrong with this because I had also made a remap.lua file, which contained some remaps and renumbering but it worked when I linked it with init.lua. The following is the code I put in the indent.lua.

    vim.opt.tabstop = 4
    vim.opt.softtabstop = 4
    vim.opt.shiftwidth = 4
    vim.opt.expandtab = true

This did not work. Can anyone help me figure this out?

like image 606
1DS19ME123 Samsak S Avatar asked Sep 16 '25 05:09

1DS19ME123 Samsak S


1 Answers

Try following the Help (:h tabstop)
This works for me in ~/.config/nvim/lua/init.lua (2 Chars Tabstop)

-- ~./config/nvim/lua/init.lua
-- called by ~/.config/nvim/init.vim with: lua require("init")
vim.opt.tabstop = 8 -- Always 8 (see :h tabstop)
vim.opt.softtabstop = 2 -- What you expecting
vim.opt.shiftwidth = 2 -- What you expecting
-- vim.opt.expandtab = true -- Works without this
like image 175
koyaanisqatsi Avatar answered Sep 19 '25 16:09

koyaanisqatsi