-
Notifications
You must be signed in to change notification settings - Fork 82
Add keymap to help writing herestrings #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add keymap to help writing herestrings #209
Conversation
| "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}, | ||
| }], | ||
| }, |
There was a problem hiding this comment.
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?
| "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''@"}, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"@?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that works.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There might be a way to simplify, rather than moving through the file one character at a time.Edit: Nope.Fixes #203