How to indent ONE line in Vscode by pressing Tab button? Vscode

Viewed 202

There are some ways to do it. CMD + }, or press Tab when you select more than one line, but I want to change keybindings or install any plugin to make my Tab button work as well as Shift + Tab do.

If there are any misunderstandings I will show an example:

enter image description here

When I press Shift + Tab the line goes left, but this line doesn't go right when I press only Tab

1 Answers
  1. Go to Keyboard Shortcuts
  2. search for indent line
  3. right-click on Indent Line entry, chose Add Keybinding...
  4. in the popup box asking for a keybinding, hit Tab and Enter to accept

You'll get a custom keybinding added to the end of your keybindings.json that looks like this:

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

You may want to change that "when" clause to

"when": "editorHasSelection && editorTextFocus && !editorReadonly"

if you want it to work only when there is a selection in the line - otherwise you'll never be able to add a Tab anywhere but the beginning of a line.

Related