1

I am using VSCode's Vim extension and it seems like the tabs are set to two spaces, but I want to change this because I work mostly in Python, which uses 4 spaces. I have found several posts/articles about changing tab spacings in Vim, but at first glance they don't seem wholly applicable since this is a VS-Code extension. I have one pre-existing mapping that I have added below.

Current Key Remap

    "vim.insertModeKeyBindings": [
        {
            "before": ["j", "j"],
            "after": ["<Esc>"]
        }
    ],

The structure should follow similar to that above, but ideally I would want my normal mode tabbing to be something like shift > > (which is the default) but with 4 spaces instead of whatever it currently is.

romainl
  • 186,200
  • 21
  • 280
  • 313
GrayLiterature
  • 381
  • 2
  • 13

2 Answers2

1

Solution

Try running: :set noexpandtab as per this wiki page.

I was having the same issue, specifically [tab] would add tabs, but the o command in Normal Mode would insert spaces on the new line. Seems to be working all around.

VSCode Settings

I would like to post my indent and tab settings so people can compare incase that's the problem as well. Please forgive my screenshots of the settings UI, I cannot be bothered going through all that JSON.

Auto Indent Settings

Detect Indentation Settings

Insert Spaces Settings

Tab Size Settings

Please let me know if I missed any relevant ones in the comments.

Or, the opposite:

It may be of use to folks who are trying to do the opposite, i.e., go from tabs to spaces, that they should use :set expandtab.

-1

I think you just have to modify in Visual Studio Code settings and not in the Vim settings.

See the post here that resume the way to do it.

  • 1
    Unfortunately this does not solve it. The editor is able to detect that the spaces are set to 4 and that Python is the language being used. Moreover, I can turn vim off and just tab like normal. – GrayLiterature Jan 12 '22 at 18:15