Diogo-Rossi / vscode-settings-switcher

Easily switch between custom setting configurations
https://marketplace.visualstudio.com/items?itemName=rossidiogo.vscode-settings-switcher
MIT License
5 stars 0 forks source link

Hotkeys to toggle settings #2

Closed dufferzafar closed 9 months ago

dufferzafar commented 1 year ago

A similar extension does this by exposing a command like settings.cycle.lineNumbers that you can then assign to keybindings.

https://github.com/hoovercj/vscode-api-playground/blob/master/SettingsCycler/src/extension.ts

Diogo-Rossi commented 1 year ago

Hi @dufferzafar could you clarify what this "hotkeys to toggle settings" feature would be? Maybe I could add this.


I searched for other extensions to "toggle settings" before making this one, there are some of then that already does this. This one was made to choose in a "list of settings", not only switch "on/off"

There is only one command Switch Settings, which can be set to a keybind

dmyger commented 10 months ago

Let me try to explain with your example to show the idea. Take a look at "Vertical rulers" section in your configuration example, there are three entries like [80, 85, 95] and it would be nice to set the Hotkey in way like it is done in Cycler

{
  "key":  "ctrl+shift+R"
  "command": "settingsSwitcher.lists.Vertical rulers"
}

And every time such a combination is pressed, the next rule from that group should be applied.

But if you want, you can go further and add extra hotkey to switch on exactly the required mode by declaring it like follows:

{
  "key":  "ctrl+shift+R ctrl+shift+8"
  "command": "settingsSwitcher.lists.Vertical rulers.Ruler 80"
}

Such a hotkey will force the necessary settings.

But that's only half of the problem. Your extension and "Settings Cycler" are too close in functionality, but both have the same issue. And yes, you offer some solution by saying that settings are only applied where they have been declared, while Cycler works always with global scope. But what killer feature was forgotten - "declare once, but use it in multiple places". At least extensions with such features are missing on Marketplace. Similar issue was raised in the Settings Cycler and was rejected with a rather odd explanation. And overall that expansion looks long abandoned. I mean here that it would be wonderful to have a "scope" option in the group to specify where it should apply. At least with two choices [global, workspace].

Diogo-Rossi commented 10 months ago

@dmyger thanks for the comment!

To clarify: the first part of your comment is related to this issue, ok. But the second part of your comment is related to the other issue ( #1 ), right?

For the hotkeys feature: I understood the request now, thank you. But I still don't see much value in this feature because once you have a list of settings to choose from, it would not be so much convenient to define a hotkey for each setting, and the cycler approach would also not be very useful.

Actually, before this extension I also tried the Toggle extension with this cycler approach. It was not practical to changing the settings I wanted by using the hotkey many times in sequence, rather to choose exactly what I was aiming in a list.

For the scope feature: That would be a very useful feature! I may look on that.

dmyger commented 10 months ago

You are right, there was two parts in my comment.

About "Toggle" - I used this extension as well, but it is extremely not user friendly. "Cycler" is made an order of magnitude better, but it is abandoned by the author and all it lacks is "scope", as described in the second part of the comment.

About cyclic switching - it works well when you need to switch 2 or at most 3 sets. If there are more sets, it is obviously better to select by list. The disadvantage of UI lists is that you have to do a lot of actions - first call the main menu, find the desired command in it and select the desired mode. The benefit of hotkeys is that they do the same thing, but only in one touch without additional time consumption.

Just as an explanation I give an example of my own use: when I need to fit more code on the screen for comparison and simultaneous work, then with a single click I get the editor in a compact view, when I work with one file, then just as quickly I get the desired more comfortable view of the IDE.

My cycler settings

"settings.cycle": [
    {
      "id": "compactLines",
      "values": [
        {
          "editor.fontFamily": "FiraCode-Retina",
          "editor.lineNumbers": "on",
          "editor.folding": true,
          "editor.glyphMargin": true,
          "window.density.editorTabHeight": "default",
          "workbench.editor.showIcons": true,
          "explorer.fileNesting.enabled": true,
          "editor.tabSize": 4,
          "vsicons.presets.hideExplorerArrows": false,
          "python.analysis.inlayHints.functionReturnTypes": true,
          "python.analysis.inlayHints.variableTypes": true,
          "python.analysis.inlayHints.pytestParameters": true,
          "python.analysis.inlayHints.callArgumentNames": true
        },
        {
          "editor.fontFamily": "Iosevka-Term-SS07",
          "editor.lineNumbers": "off",
          "editor.folding": false,
          "editor.glyphMargin": false,
          "window.density.editorTabHeight": "compact",
          "workbench.editor.showIcons": false,
          "explorer.fileNesting.enabled": false,
          "editor.tabSize": 2,
          "vsicons.presets.hideExplorerArrows": true,
          "python.analysis.inlayHints.functionReturnTypes": false,
          "python.analysis.inlayHints.variableTypes": false,
          "python.analysis.inlayHints.pytestParameters": false,
          "python.analysis.inlayHints.callArgumentNames": false
        }
      ]
    }
  ]
Diogo-Rossi commented 10 months ago

@dmyger thank you for your message!

About cyclic switching - it works well when you need to switch 2 or at most 3 sets. If there are more sets, it is obviously better to select by list. The disadvantage of UI lists is that you have to do a lot of actions - first call the main menu, find the desired command in it and select the desired mode. The benefit of hotkeys is that they do the same thing, but only in one touch without additional time consumption

Ok, I will look on that. Maybe there is a way to pass arguments to the hotkey command that could get the result we are discussing.

About the other feature:

I mean here that it would be wonderful to have a "scope" option in the group to specify where it should apply. At least with two choices [global, workspace].

I will reopen the other issue ( #1 ) and work on this. I think it is easy to achieve.

Diogo-Rossi commented 10 months ago

@dmyger

I mean here that it would be wonderful to have a "scope" option in the group to specify where it should apply. At least with two choices [global, workspace].

Done. I've add an observation to README.

Diogo-Rossi commented 9 months ago

@dufferzafar and @dmyger

Thank you for your comments!

I added this "Hotkeys feature" in v0.8.0


Now, the command switchSettings accepts arguments. You can pass these arguments with keybidings (hotkeys).

The "args" object accepts 3 properties: "group", "definition" (which are strings) and "cycler" (which is a boolean).

you can go further and add extra hotkey to switch on exactly the required mode

This is achieved by using "group" and "definition" properties in the keybiding "args".

it would be nice to set the Hotkey in way like it is done in Cycler

This is achieved by using "group" and "cycler" (with boolean true) in the keybiding "args".

The benefit of hotkeys is that they do the same thing, but only in one touch without additional time consumption.

Others combinations of "group", "definition" and "cycler" properties are possible, which may save time.

I added a new section in README describing that.

Thank you again for your comments!