-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Plugin proposal: Surround #610
Comments
Definitely gets a thumbs up from me. I'm down to implement it with a flag that is on by default as it doesn't The surround.vim plugin is only about 600 lines: Even though I don't really understand viml, the source doesn't seem that On Mon, Aug 15, 2016 at 4:21 PM, Aiden Scandella notifications@github.com
Grant |
Wow, this issue has certainly gotten a lot of activity. PRs welcomed. 😉 |
I actually started looking into implementing it but couldn't figure out how to bind the keys properly. I'll push my branch up showing what i tried and let an expert explain why it wasn't working... |
So regardless of what business logic is necessary, I was looking into how to hook up the keybindings correctly. I tried adding this to diff --git i/src/actions/actions.ts w/src/actions/actions.ts
index 3f542ba..f9b1001 100644
--- i/src/actions/actions.ts
+++ w/src/actions/actions.ts
@@ -1097,6 +1097,16 @@ export class ChangeOperator extends BaseOperator {
}
@RegisterAction
+export class ChangeSurroundOperator extends BaseOperator {
+ public keys = ["c", "s"];
+ public modes = [ModeName.Normal];
+
+ public async run(vimState: VimState, start: Position, end: Position): Promise<VimState> {
+ return vimState;
+ }
+}
+
+@RegisterAction
export class PutCommand extends BaseCommand {
keys = ["p"];
modes = [ModeName.Normal]; (and then put a breakpoint inside But it wouldn't match the chord. I'm pretty sure I'm missing something obvious, but this is when I stopped and went back to my crushing backlog of "real" (aka paid) work |
My best guess is that the change operator gets triggered immediately when you press "c", so an action with "c" "s" can't be triggered. |
A better idea might be to make "s" plus whatever actions come next for the surround command into movements and handle them specially in the change operator class. |
Yea, I've stared at this a few times and not gotten anywhere in my limited freetime. I'm trying to look for prior art where a movement/command takes input after, but all I've found is stuff like the code for I think I just need to read through the entire codebase to truly understand the right place to hook everything in. |
Believe it or not, but as far as we've gotten, we don't actually have any commands that take input after being triggered. The only real equivalent we have is the /, which actually drops you into a new state while it's taking new input (a rather complex solution for what you want to do). What we do have is operator objects that can be combined with motion objects that come later. If you do So if you want to handle something like Then once the motion was finished and the change operator was finally run, you could look for the stuff that I have to say though, it looks like our current infrastructure is not 100% ready for surround. Along with the above issue, I also see:
|
I do not mind myself working in vim without surround plugin. Thats bad that you have implementation issues for now. Still like your vim plugin the most. |
Oh. The implementation issues I was talking about should certainly not stop anyone from trying to implement surround. They're just things to take note, not show stoppers! |
Might be a little easier to read if someone is looking for ideas on how this could be done https://github.com/jcartledge/sublime-surround/blob/master/Surround.py |
I said I wouldn't do it, but then I did it anyways: Surround.vim has been added to VSCodeVim as of #1238 and v0.5.0. Please try it out and let me know how it works. I have never used Surround in my life, so it's very possible that I am missing some things. :) |
I've been on the fence all weekend about sticking with vim or switching to vscode. This PR has made my decision significantly easier. Not everything is seamless from vim yet, but boy is it close, and I'm confident now that it'll get there. Your momentum and dedication to the project is laudable - thank you! (Also, thanks for the reminder of the donation link. Totally worth "paying" for features like this) |
@johnfn is a legend |
/me bows
…On Tue, Jan 24, 2017 at 4:29 PM Sean Kelly ***@***.***> wrote:
@johnfn <https://github.com/johnfn> is a legend
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#610 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAF7P7665cir5uRv1-___upw9M3qOYITks5rVpK_gaJpZM4Jkh5T>
.
|
Sub-issue of #590
I, along with others, are interested in getting TPope's surround plugin implemented here.
I don't really understand ViML so it would likely be a re-implementation rather than a transcription.
Leaving this issue open for others to subscribe and possibly contribute to. Eventually if I have enough free time I will try to implement myself. It will likely be a subset (for example, I don't even use tags like
ysiw<em>
but if the architecture is correct this shouldn't be too hard.cc @rebornix
NOTE: per discussion on other tickets, this would be a "core" feature (e.g. not a separate plugin/requirejs) that would be behind a feature flag.
Open question: on by default, or off by default?
The text was updated successfully, but these errors were encountered: