Open ShortArrow opened 2 years ago
I personally consider multi-cursor editing to be a symptom of repetitive code. I wouldn't want to support it for myself. It also is not really a language feature, but an editor feature.
Any implementation of this by Rubberduck would require we completely overhaul the internal editing process in the VBE, something we've been wanting to do for quite a while now, but have never gotten real progress on... Until we can safely and cleanly "replace" the VBE within the VBE (after all this still is an add-in), the complexity of this issue sounds prohibitive in comparison to the benefit it provides.
Compare for a discussion of the complexities: #5152, #4892 and #5375
and adopt a language that can be used with vscode.
@ShortArrow Mind, you can code VBA perfectly well in VSCode, as long as you are happy to lose intellisense and compile time error checking.
I personally consider multi-cursor editing to be a symptom of repetitive code.
@Vogel612 Sometimes such code (especially in VBA) is unavoidable, and multi-line cursor is a godsend in these scenarios. If you don't believe me, here is an example. Or an excerpt:
Private WithEvents pUserForm as MSForms.UserForm
Private WithEvents pFrame as MSForms.Frame
Private WithEvents pMultiPage as MSForms.MultiPage
Private WithEvents pLabel as MSForms.Label
Private WithEvents pImage as MSForms.Image
Private WithEvents pTabStrip as MSForms.TabStrip
Private WithEvents pTextBox as MSForms.TextBox
Private WithEvents pComboBox as MSForms.ComboBox
Private WithEvents pListBox as MSForms.ListBox
Private WithEvents pCheckBox as MSForms.CheckBox
Private WithEvents pOptionButton as MSForms.OptionButton
Private WithEvents pToggleButton as MSForms.ToggleButton
Private WithEvents pScrollBar as MSForms.ScrollBar
Private WithEvents pSpinButton as MSForms.SpinButton
Private WithEvents pCommandButton as MSForms.CommandButton
'... later
select case iCtrlType
Case uiUserForm: set ctrl = oControls.Add("Forms.Form.1", sName)
Case uiFrame: set ctrl = oControls.Add("Forms.Frame.1", sName)
Case uiMultiPage: set ctrl = oControls.Add("Forms.MultiPage.1", sName)
Case uiLabel: set ctrl = oControls.Add("Forms.Label.1", sName)
Case uiImage: set ctrl = oControls.Add("Forms.Image.1", sName)
Case uiTabStrip: set ctrl = oControls.Add("Forms.TabStrip.1", sName)
Case uiTextBox: set ctrl = oControls.Add("Forms.TextBox.1", sName)
Case uiComboBox: set ctrl = oControls.Add("Forms.ComboBox.1", sName)
Case uiListBox: set ctrl = oControls.Add("Forms.ListBox.1", sName)
Case uiCheckBox: set ctrl = oControls.Add("Forms.CheckBox.1", sName)
Case uiOptionButton: set ctrl = oControls.Add("Forms.OptionButton.1", sName)
Case uiToggleButton: set ctrl = oControls.Add("Forms.ToggleButton.1", sName)
Case uiScrollBar: set ctrl = oControls.Add("Forms.ScrollBar.1", sName)
Case uiSpinButton: set ctrl = oControls.Add("Forms.SpinButton.1", sName)
Case uiCommandButton: set ctrl = oControls.Add("Forms.CommandButton.1", sName)
end select
'... later ...
select case pType
Case uiUserForm: set uiObject = pUserForm
Case uiFrame: set uiObject = pFrame
Case uiMultiPage: set uiObject = pMultiPage
Case uiLabel: set uiObject = pLabel
Case uiImage: set uiObject = pImage
Case uiTabStrip: set uiObject = pTabStrip
Case uiTextBox: set uiObject = pTextBox
Case uiComboBox: set uiObject = pComboBox
Case uiListBox: set uiObject = pListBox
Case uiCheckBox: set uiObject = pCheckBox
Case uiOptionButton: set uiObject = pOptionButton
Case uiToggleButton: set uiObject = pToggleButton
Case uiScrollBar: set uiObject = pScrollBar
Case uiSpinButton: set uiObject = pSpinButton
Case uiCommandButton: set uiObject = pCommandButton
end select
So yes, definitely repetitive, however definitely infinitely valuable, as with this class we have every UI element wrapped and no longer do we need hundreds of event handlers. I.E. In the pursuit of non-repetitive code sometimes you absolutely have to write repetative code, especially in VBA. Which is why a feature such as this is valuable.
However I know this is likely impossible to actually implement with the current architecture.
In response to the original post I'd volunteer that I have been using twinBasic with VSCode for a while now (for hobby projects). With Rubberduck installed, and sticking to strict VBA, its perfectly possible to round trip to VSCode/twinBasic and back to the VBA ide. Enforcing Strict VBA compatibility is made easier if you round trip for Rubberduck inspections on a frequent basis.
Another valid usecase for multi-cursor that I have seen is when you want to massage raw data into a variable - e.g. you copy a list of country names from wikipedia, you need to add quotes and commas and store it in an array or wrap in a list constructor. Anything you might copy to an Excel worksheet, then use TEXTJOIN/CONCAT to reassemble into VBA, that can be helped with multi-cursor editing (or regex find/replace).
Justification
This feature is one of the reasons why I want to reject VBA and adopt a language that can be used with vscode.
Description
Add Multi-cursor editing feature like vscode of Multi-Cursor Editing