Home Download Buy Blog Forum Support

how to: select previous auto-complete item

how to: select previous auto-complete item

Postby SimplyPhy on Wed Nov 14, 2012 8:41 pm

Hello!

I am having a great deal of difficulty modifying some of the hotkeys in ST2. I would like to create a hotkey (or modify/discover the existing hotkey) for selecting the previous auto-complete item. More specifically, I want a hotkey to do exactly the opposite of what ctrl + space does when you have an auto-complete listing active.

This is the code for ctrl + space, as found within the default key bindings:

{ "keys": ["ctrl+space"], "command": "auto_complete" },
{ "keys": ["ctrl+space"], "command": "replace_completion_with_auto_complete", "context":
[
{ "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false },
{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
]
},

I'm not an experienced programmer, and I cannot understand this.

Also, whenever I input and save code into "Key Bindings - User", I receive no effect. I've done this with code provided by others in this forum. Is there a common error in activating new "Key Bindings - User" commands?

Using win7 64bit.

Thank you!
SimplyPhy
 
Posts: 4
Joined: Wed Nov 14, 2012 8:33 pm

Re: how to: select previous auto-complete item

Postby agibsonsw on Wed Nov 14, 2012 9:02 pm

I use the following set of key-bindings so that I can use ctrl-alt-right and ctrl-alt-left to cycle forward and back through the completions.

Code: Select all
   { "keys": ["ctrl+alt+right"], "command": "insert_best_completion", "args": {"default": "", "exact": true} },
   { "keys": ["ctrl+alt+right"], "command": "insert_best_completion", "args": {"default": "", "exact": false},
      "context":
      [
         { "key": "setting.tab_completion", "operator": "equal", "operand": true }
      ]
   },
   { "keys": ["ctrl+alt+right"], "command": "replace_completion_with_next_completion", "context":
      [
         { "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
         { "key": "setting.tab_completion", "operator": "equal", "operand": true }
      ]
   },
   { "keys": ["ctrl+alt+left"], "command": "replace_completion_with_prev_completion", "context":
      [
         { "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
         { "key": "setting.tab_completion", "operator": "equal", "operand": true }
      ]
   }

Check your key-bindings to ensure that you don't have a spare, or missing, comma. Check the console Ctrl ' (apostrophe) for any error message(s).

You could paste a copy of your current key bindings here if you want.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: how to: select previous auto-complete item

Postby SimplyPhy on Thu Nov 15, 2012 8:01 pm

That's great, thanks for the help @agibsonsw!

I don't have time today, but I'll test this tomorrow.
SimplyPhy
 
Posts: 4
Joined: Wed Nov 14, 2012 8:33 pm

Re: how to: select previous auto-complete item

Postby SimplyPhy on Sun Nov 18, 2012 8:12 pm

Thank you again for that code, @agibsonsw. I do like the ability that that keycode configuration allows for, but unfortunately I don't think can serve me in the way that I'm looking for right now.

So I must ask again: does anyone know how I can configure the exact opposite of the ctrl+space function? I really am just at a loss to figuring it out, I don't understand how to reconfigure the JSON. My initial post explains exactly what I mean.

Thank you!
SimplyPhy
 
Posts: 4
Joined: Wed Nov 14, 2012 8:33 pm

Re: how to: select previous auto-complete item

Postby agibsonsw on Sun Nov 18, 2012 9:33 pm

No worries, but I think you need to clarify your request, as the exact opposite of Ctrl-Space could just mean Undo (Ctrl-Z), and 'previous completion' is also ambiguous.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: how to: select previous auto-complete item

Postby SimplyPhy on Wed Nov 21, 2012 4:56 am

@agibsonsw

Sorry, what I mean is that, when I am coding, the auto-completion tab/popup emerges while I write, for example, "bac" in CSS to show me that I can auto-complete "bac" with the word background, etc etc. Now, to scroll down this auto-complete listing, I can use "ctrl+space", and I will visually see that the next auto-complete option is highlighted. I can, at any point, press "enter" to select the currently highlighted auto-complete option.

I like this feature very much, but I cannot figure out how to get the auto-complete to highlight the option above the currently highlighted option. I can just continue to press "ctrl+space" until I go through the entire listing, but this can require many clicks depending on how many options are present. That's what I meant by the opposite of "ctrl+space". And obviously the hotkeys 'could' be configured to do this, since they can cause the highlighted option to move down, I just can't decipher the JSON (the code I sent in my first message) adequately to recode it to highlight the previous selection instead of the following selection.

Sorry again, I'm trying to be as clear as possible. Thanks for sticking with me!
SimplyPhy
 
Posts: 4
Joined: Wed Nov 14, 2012 8:33 pm

Re: how to: select previous auto-complete item

Postby agibsonsw on Wed Nov 21, 2012 3:44 pm

Not sure how you would achieve this - I just use the Up and Down arrows or make use of the fuzzy-searching ability by entering letters that only appear in certain completions.

Perhaps someone else can advise you. Soz, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm


Return to General Discussion

Who is online

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