-
Notifications
You must be signed in to change notification settings - Fork 301
Autocompletion
Autocompletion is disabled by default. The 'Autocompletion Settings' tab of the 'Settings' dialog lets you enable each sub-feature individually:
image as of v2.2.0.4100; subject to change.
Enable autocompletion features
This checkbox determines whether Rubberduck responds to a keypress in the active code pane.
Enable self-closing pairs
Determines whether Rubberduck swallows a keypress and takes over the VBE, depending on context-sensitive information from the current logical line of code.
Enable smart-concatenation
Determines whether Rubberduck handles the ENTER key when the caret is inside a string literal.
-
Concatenate 'vbNewLine' on Ctrl+Enter
Determines whether Rubberduck handles the CTRL+ENTER key combination when the caret is inside a string literal.
Enable block completion
Determines whether Rubberduck captures a set of specific block-starting tokens when the SPACE key is pressed after typing them. Once captured, any keypress other than ENTER or TAB (as configured) cancels block completion.
One or both of the following settings must be enabled:
-
Autocomplete blocks on ENTER
Makes the ENTER key trigger block completion given a captured block-starting token. -
Autocomplete blocks on TAB
Makes the TAB key trigger block completion given a captured block-starting token.
When the self-closing pairs feature (SCP) is enabled, Rubberduck will capture a keypress in specific conditions. Pairs are defined by an opening and a closing single-character token - the list is hard-coded for now:
Opening | Closing |
---|---|
" | " |
( | ) |
[ | ] |
{ | } |
A self-closing pair is said to be symetric when the opening and closing characters are the same; SCP handling has special rules for symetric pairs, that don't necessarily presume the pair delimits a string literal.
Note that SCP will generally not be handled for a keypress of either the opening or closing character when the caret position is inside a comment or string literal.
The base behavior is that when the keypress matches the opening character of a self-closing pair, Rubberduck completes the pair by inserting both the opening and closing characters, placing the caret between the two, replacing the entire current logical line of code, and then preventing the keypress from reaching the code pane.
For example, given "
for input on this code (where |
denotes the caret position):
Original | Input | Result |
---|---|---|
msgbox | |
" |
MsgBox "|" |
Self-closing pairs close themselves, so when the caret is immediately to the left of a pair-closing character, typing that pair-closing character will simply move the caret one position to the right - resulting in exactly the same outcome as if you would have typed it:
Original | Input | Result |
---|---|---|
MsgBox "|" |
" |
MsgBox ""| |
If the next character isn't the pair-closing character being input, and that input matches a SCP opening character, pairs get nested:
Original | Input | Result |
---|---|---|
msgbox (|) |
" |
MsgBox ("|") |
The BACK key is handled by a SCP when the caret immediately follows a pair-opening character... and that the pair is closed. If handled, both the pair-opening and pair-closing characters are removed from the logical line, i.e. irrespective of line continuations.
Original | Input | Result |
---|---|---|
MsgBox "|" |
{BACK} |
MsgBox| |
Debug.Print ((|2 + 2) + _ (2 - 2) - _ (2 + 2)) |
{BACK} |
Debug.Print (|2 + 2 + _ (2 - 2) - _ (2 + 2)) |
Debug.Print (|(2 + 2) + _ (2 - 2) - _ (2 + 2)) |
{BACK} |
Debug.Print |(2 + 2) + _ (2 - 2) - _ (2 + 2) |
When typing a multi-line string literal, Rubberduck assists by automating the " & _
on the caret line, and the {indent}"|"
on the next line... keeping in mind that VBA will not compile an instruction that spans more than 25 lines.
Original | Input | Result |
---|---|---|
MsgBox "Lorem ipsum dolor sit amet, |" |
{ENTER} |
MsgBox "Lorem ipsum dolor sit amet, " & _ "|" |
MsgBox "Lorem ipsum dolor sit amet, |" |
{CTRL}+{ENTER} |
MsgBox "Lorem ipsum dolor sit amet, " & vbNewLine & _ "|" |
In both cases, when the caret line contains only a pair of double quotes, the smart-concatenation can be undone by a single BACK keypress:
Original | Input | Result |
---|---|---|
MsgBox "Lorem ipsum dolor sit amet, " & vbNewLine & _ "|" |
{BACK} |
MsgBox "Lorem ipsum dolor sit amet, |" |
[coming soon]
rubberduckvba.com
© 2014-2021 Rubberduck project contributors
- Contributing
- Build process
- Version bump
- Architecture Overview
- IoC Container
- Parser State
- The Parsing Process
- How to view parse tree
- UI Design Guidelines
- Strategies for managing COM object lifetime and release
- COM Registration
- Internal Codebase Analysis
- Projects & Workflow
- Adding other Host Applications
- Inspections XML-Doc
-
VBE Events