On Atom (and many other editors), there is the auto-indent command which allows us to auto-indent the line the cursor is on. Is there an equivalent in Visual Studio Code ?
I know there is the formatter action on Visual Studio Code but from what i have seen, it can be used only to :
I would like to be able to format the line the cursor is on without reformating the whole document and without having to make a selection.
Basically, i would like to configure the [TAB] key so that when i press [TAB], it auto-indents only the line the cursor is on :
Is it possible ?
Use either of the two ways to indentation the code: Shift + Tab , Ctrl + k + f .
You (these are the default settings I believe) can select a block of code and press the Tab key. This will indent the entire block. So for indenting a whole file: Ctrl + A , then Tab .
So I have skimmed through the source code and seems there is no setting currently available to make this happen. There is a lot of work happening in pipeline for indentation
https://github.com/Microsoft/vscode/issues/17868
VSCode use Monaco Editor under the hood
https://github.com/Microsoft/monaco-editor/issues/612
The current python configs are located in
https://github.com/Microsoft/vscode/tree/master/extensions/python
I tried, but understanding how all this integrates and works together just to fix one indent issue was just overwhelming. So I would just for the time being open a enhancement request with VScode and let the experts take a call and do the job
Allow me to humbly suggest that you are looking for the solution in the wrong place.
I would suggest the following setting:
"editor.formatOnType": true,
You have focused on "tab" doing the correct indentation. But with this setting you need not press the tab key at all. Just type the line with a normal return at the end. Visual Studio Code will then indent (and format) that line correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With