Home Download Buy Blog Forum Support

Vintage - Keep selection going from Visual to Insert mode

Vintage - Keep selection going from Visual to Insert mode

Postby JosephFerano on Mon Apr 29, 2013 6:36 am

Hello, first of all, I love ST2 and Vintage!

I am having a bit of an issue though, is it at all possible to go from Visual Mode to Insert Mode and still keep the selection alive? I find that pressing I or A eliminates the selection I had. Thank you for the help.
JosephFerano
 
Posts: 2
Joined: Mon Apr 29, 2013 6:30 am

Re: Vintage - Keep selection going from Visual to Insert mode

Postby Stubblechunks on Wed May 08, 2013 2:03 am

I have not found any way to make it so. It's a shame; vintage mode makes it much easier to add to a selection without moving your hands. But then you're pretty limited in visual mode as far as what you can DO with that selection.
Stubblechunks
 
Posts: 24
Joined: Wed Apr 24, 2013 8:35 pm

Re: Vintage - Keep selection going from Visual to Insert mode

Postby skuroda on Wed May 08, 2013 3:48 am

Have you tried a custom key binding? This might work.

Code: Select all
{ "keys": ["i"], "command": "enter_insert_mode",
      "context":
      [
            {"key": "setting.command_mode"},
            { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": false }
      ]
    }
skuroda
 
Posts: 685
Joined: Fri Oct 05, 2012 8:11 am

Re: Vintage - Keep selection going from Visual to Insert mode

Postby Stubblechunks on Wed May 08, 2013 2:02 pm

skuroda wrote:Have you tried a custom key binding? This might work.

Code: Select all
{ "keys": ["i"], "command": "enter_insert_mode",
      "context":
      [
            {"key": "setting.command_mode"},
            { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": false }
      ]
    }


Wow. "Might work"? Did you just wing that? I pasted it straight into my user keybindings file and it works without any modification. Most of the values you use in the "context" section are not documented on the web pages I've seen on keybindings. Could you point me toward an explanation of that material?

Thanks a billion. Bringing my selection back with me from Visual mode makes life so much better.
Stubblechunks
 
Posts: 24
Joined: Wed Apr 24, 2013 8:35 pm

Re: Vintage - Keep selection going from Visual to Insert mode

Postby skuroda on Wed May 08, 2013 5:45 pm

"Might work" was because I didn't test it very well. For context, I skimmed through the vintage key bindings and use http://docs.sublimetext.info/en/latest/ ... -a-context. When I was trying to learn a bit more about context, I also looked through the default key bindings as there are a number of context entries in there. :)

Hope that helps.
skuroda
 
Posts: 685
Joined: Fri Oct 05, 2012 8:11 am

Re: Vintage - Keep selection going from Visual to Insert mode

Postby unphased on Sat Aug 10, 2013 4:21 am

So, this is amazing, hooray!

But, I'd like to learn about this crazy sublime key bind magic, and I'm having a tough time understanding the logic that makes this work.

Is it the "match_all" that makes it also work when the selection *is* empty?


I will also take this time to point out that you may want to not use "i" to bind that, as "i" in the context of a visual selection (in vim and vintage) is actually for selecting the inside of some thing ("a" for tag, "b" for parens, "B" for brackets, and all those keys like ", (, {, [, etc.), which is highly useful.

Since what we're looking at here is switching from vim-behavior to sublime-behavior (transitioning from the vintage visual mode to insert mode while keeping the selection alive) it would make more sense to bind it to another key.

I wonder what a good key for that would be. Hmmm. Well, technically anything other than "a" or "i" should be good because of how ST binds expose more State Machine guts than Vim does, and the state here is "vi_can_enter_text_object".

Sublime binds can be made to work much more precisely because of this.

I'm going to use "e" for "edit".
unphased
 
Posts: 28
Joined: Thu May 17, 2012 5:16 am


Return to General Discussion

Who is online

Users browsing this forum: Exabot [Bot] and 17 guests