Make (
/[
/{
/T
/F
surrounds on visual line indent wrapped lines
#8077
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
The surround plugin implementation is mostly great, but one thing I miss is a way to automatically indent the surrounded text in visual line mode. To my knowledge this wasn't supported in the original vim plugin either, but I'd argue that the current behaviour isn't exactly intuitive:
VS{
currently results in:This PR changes the visual line mode behaviour of the surround keys that usually wrap the content with a space (
(
/[
/{
/T
/F
) to instead indent the surrounded line(s). The indentation for the delimeters are determined from the first line, with surrounded lines being indented one more level. With this PR the previous example will instead result in:Surrounds with
)
/]
/}
/t
/f
behave as before, as well as regular visual mode surrounds.I also added Enter to the list of supported surround keys, which will wrap the selection in a multiline curly brace block (even outside visual line mode).
``` Home |Contact ``` `VkSTnav` results in: ``` Home Contact ```Additional examples
VkSFconsole.log<Enter>
results in:ysiw<Enter>
results in:Which issue(s) this PR fixes
Special notes for your reviewer:
Two tests are failing - I'm struggling to get the cursor position to be where expected, would love to hear some ideas on how to solve it. I've seen that cursor position after surround actions have been problematic in general going by the number of issues referencing it.