Skip to content

Conversation

@michaelblyons
Copy link
Collaborator

@michaelblyons michaelblyons commented Dec 9, 2025

There might be a way to simplify, rather than moving through the file one character at a time. Edit: Nope.

Fixes #203

@michaelblyons michaelblyons added this to the 4.2.0 milestone Dec 9, 2025
@michaelblyons michaelblyons added the autocomplete Snippets, word-completion, and macros label Dec 9, 2025
@michaelblyons michaelblyons merged commit 4030791 into SublimeText:master Dec 9, 2025
@michaelblyons michaelblyons deleted the herestring-macro branch December 9, 2025 23:39
Comment on lines +34 to +55
"command": "chain",
"args": {
"commands": [{
"command": "insert",
"args": {"characters": "'\n" },
}, {
"command": "run_macro_file",
"args": {"file": "res://Packages/Default/Delete to Hard BOL.sublime-macro"},
}, {
"command": "insert",
"args": {"characters": "'@" },
}, {
"command": "move",
"args": {"by": "characters", "forward": false},
}, {
"command": "move",
"args": {"by": "characters", "forward": false},
}, {
"command": "move",
"args": {"by": "characters", "forward": false},
}],
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the following insert_snippet achieve the same?

Suggested change
"command": "chain",
"args": {
"commands": [{
"command": "insert",
"args": {"characters": "'\n" },
}, {
"command": "run_macro_file",
"args": {"file": "res://Packages/Default/Delete to Hard BOL.sublime-macro"},
}, {
"command": "insert",
"args": {"characters": "'@" },
}, {
"command": "move",
"args": {"by": "characters", "forward": false},
}, {
"command": "move",
"args": {"by": "characters", "forward": false},
}, {
"command": "move",
"args": {"by": "characters", "forward": false},
}],
},
"command": "insert_snippet",
"args": { "contents": "$0''@"},

Copy link
Collaborator Author

@michaelblyons michaelblyons Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try it when I get to a computer, but I don't think so. The newlines in PS are significant parts of the herestring. Both in the opening and closing.

From this (pipe is caret):

    $foo = @|

The objective is to type " and end with

    $foo = @"
|
"@

no matter what the original indentation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just the insert and the three moves could be replaced with an insert_snippet $0\n"@?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the intented behavior happening on my Windows box. Typing ' ends up with @''@, using keybindings from this PR.

Copy link
Collaborator Author

@michaelblyons michaelblyons Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh weird. I really thought I tested this both against master and refactor. And it's not working right (but not in the same way as you have). Luckily, the new PR seems to work.

michaelblyons added a commit that referenced this pull request Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autocomplete Snippets, word-completion, and macros

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatically type the end of herestrings

2 participants