tabsvisual-studio-code

VSCode insert tab character manually


When using VSCode, most of my files are set to be indented using spaces. However I sometimes wish to insert a literal tab. When I was using vim I'd use <Ctrl>+v <Tab> but that doesn't work with VSCode.

I've been searching and searching and cannot find anything. Please help!


Solution

  • I'm not sure if there is a generic solution, but you can setup a keybinding for this:

    {
        "key": "ctrl+v tab",
        "command": "type",
        "args": { "text": "\t" },
        "when": "editorTextFocus"
    }
    

    This keybinding will insert an tab character even when the current mode is spaces.