Preamble:
I would like to use VS Code whenever i can, if i could (mainly for the reason that it is cross-platform and the only completely customizable/hackable GUI editor on all major platforms).
One issue although breaks my workflow repeatedly; while it is merely an interruption its impact on being able to keep focus is measurable. Before we get to that let me describe ...
The Status quo:
I defined in the settings to use the tab-key solely for auto-completion of code-snippets and disabled allowing the enter-key for completion.
This is intended and working fine.
For languages that are indentation-based i enabled the acceptance and conversion of tab-stop/tab-key-input to the (by the linter/intellisense) given default-width. Where necessary I override it either project-based or profile-based.
This is intended and working fine.
Also the behavior to keep treating the converted-to-spaces tab-stops as such is activated.
This is intended and working fine.
That said, here comes my ...
Targeted Configuration:
Requirement A
Block the insertion of tab-stops in general whenever it is not explicitly allowed or does not pass the linter/intellisense.
Meaning: the only case when a tab-key-input should be treated as tab-stop-insertion is solely in indentation-based languages and even then solely in the case it fullfils the given syntax-requirements for that language to the point.
Requirement B
The tab-key should otherwise solely be used to navigate semantically/syntactically; for example to the next possible virtual insertion-field as defined by the linter, intellisense, emmet, etc.
Requirement C
The only edge-case where an insertion shall be executed is if the scope allows to nest following content aka insert an indentation level.
But only then.
Preferable bonus outcome:
The tab-key should trigger full-closure and leave-of-scope if the tab-key is pressed right after a command was entered and can not be further extended; or alternatively in languages which do have special ending-characters (like the famous ";"/semicolon in C/ECMA-style languages) then if the tab-key is pressed while the cursor is right of that ending character it must/has to trigger the closure of the scope and jump accordingly to the upper indentation layer.
Request:
Any input on how to reach the necessary outcome for A AND B AND C is appreciated.
If a solution requires to use an addon, this is fine by me, as long as that addon can be used in the "Visual Studio Code for the Web" live/online version.
Preferable would be a solution that requires only a regular customization of the settings.
To add what I so far consider as a required preface to a possible solution (since I have rigorously tried all possible combinations of tab-completion, tab-switch, formatting of tab-stops, etc. that are defined in settings by default) is (still an assumption):
Fully disabling the acceptance of the tab-key to be treated as input at all, to create a blank slate to start from:
{
"key": "tab",
"command": "-editor.action.insertSnippet",
"when": "editorTextFocus && !editorReadonly"
}
"key"[...] => The key pressed this should apply to "command" [...] => the minus/dash removes the action "when" [...] => ensures that the keybinding only works when the text editor is in focus and not in read-only mode (allowing to use tab-switch to jump between VS Code subwindows/components, not necessary, but nice side-effect)
For indentation-based languages (exemplary: Python)
{
"key": "tab",
"command": "editor.action.indentLines",
"when": "editorTextFocus && !editorReadonly && editorLangId == 'python'"
}
.. which solves part of the problem, but the navigation and closure/scope-leave is missing.
I "think" i need to somehow define a custom jump-command/-action that binds the accordingly (to the language) defined linter/intellisense/etc. ... ?
I am simply not able to figure out how to describe this behavior in the settings. Let alone be able to tell if the path I thought up, is helpful at all.
If it is of importance, this is a list of languages i "wish" to edit/input in the requested way:
- C / C++ / C#
- JavaScript / TypeScript / ES 7/8/n
- GD-Script
- Commodore/Microsoft Basic
- CPM
- Lazarus (Object) Pascal
- Python / YAML / Guile / Assembly
- Haskell / Common Lisp / Erlang / SmallTalk / Lua
These are not requirements, just exemplary languages; meaning if someone might be able to point out a (part of a) possible solution for one of these languages i might/will be able to create a universal template that can be extended.
Refinement of the "question" is appreciated, especially layout-wise, the sequence I laid out the content is not - I decided on purpose to comb the horse from the tail.
Partial Solutions should be an answer not a comment.
Thanks for taking the time to give this a thought.