visual-studio-codeindentationtext-indent

Visual Studio Code - Indent single line with tabulator-key


I would like to know if its possible to indent a single line with the tab-key without deleting the marked text.

In the first part of the GIF you see Visual Studio Code and in the second part Atom. Atom shows the desired behaviour.

First: VS Code, Second: ATOM-Editor

Thus far it is possible to indent multiple lines this way in VS Code, it also works with backtab, but not with tab and a single line.

VS Code indent multiple lines

Is this a bug or normal behavior??

My Setup:
Visual Studio Code: Version 1.25.1 (MacOS 10.13.6 High Sierra)
Visual Studio Code: Version 1.25.1 (Ubuntu 18.04 LTS)


Solution

  • You could use this default keybinding:
    
    {
      "key": "ctrl+]",
      "command": "editor.action.indentLines",
      "when": "editorTextFocus && !editorReadonly"
    }
    

    to tab single or multilines. If you want that bound to tab you could modify it to:

    {
      "key": "tab",
      "command": "editor.action.indentLines",
      "when": "editorHasSelection && editorTextFocus && !editorReadonly"
    }
    

    I added the editorHasSelection clause so it operates only when something is selected on your line, but then you would lose the normal simple tab behavior (that you don't like).