Sublime Forum

Help needed changing user keybindings!

#1

Hello community,

I am new to coding but would like to use sublime as my markdown writer.
I need to type in Japanese, and therefor there are lots of keybindings that get into conflict with this.

What I want to do:

I need to remove the “tab” function after I have typed, since we use it to select the characters we want (the kanji). But I want to keep the “tab” function if nothing is typed in.

In many guides they tell me to add “//” in front of these lines: (94-101)

[code] { “keys”: “tab”], “command”: “insert_best_completion”, “args”: {“default”: “\t”, “exact”: true} },
{ “keys”: “tab”], “command”: “insert_best_completion”, “args”: {“default”: “\t”, “exact”: false},
“context”:

		{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
	]
},[/code]

But in ST3, it seems to be impossible to save them in “default”, and if I copy them into the “user key-bindings” with “//” in front of it, it still won’t work properly…

Can anyone help me with this?

0 Likes

#2

Your problem is that “//” just comments the line.

Sublime Text looks in defaults and sets them, and then looks in user and ignores the commented lines – but the defaults are still there!

You’d want (untested):

   { "keys": "tab"], "command": "unbound" },

Which will override with a null-op, if that makes sense.

0 Likes

#3

ST3 runs out of the .sublime-package files, rather than needing to be extracted. That is why you can’t edit it. This is safer in a sense as your modifications will not be overridden in future updates. You can try one of two things. The first is to override the keybinding file. To do this, I would recommend using PackageResourceViewer. Simply open the file with that plugin, make your modification, and save. It will place the file in the correct location. The second solution is to keep your modifications in the user directory. I’m not quite clear on what you are trying to do. Well, more the part where you say “I want to keep the tab functionality if nothing is typed in”. If you could clarify that, I might be able to help more.

@veedrac

I believe that will also keep you from ever inserting a tab, which I’m guessing isn’t desired (though I could be wrong).

0 Likes

#4

[quote=“skuroda”]
@veedrac

I believe that will also keep you from ever inserting a tab, which I’m guessing isn’t desired (though I could be wrong).[/quote]

Ah, on second read I think Mesqueeb wants something more like:

	{ "keys": "tab"], "command": "unbound" },
	{ "keys": "tab"], "command": "unbound",
		"context":
		
			{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
		]
	},
	{ "keys": "tab"], "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": "tab"], "command": "reindent", "context":
		
			{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
			{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
			{ "key": "preceding_text", "operator": "regex_match", "operand": "^$", "match_all": true },
			{ "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true }
		]
	},
	{ "keys": "tab"], "command": "indent", "context":
		
			{ "key": "text", "operator": "regex_contains", "operand": "\n" }
		]
	},
	{ "keys": "tab"], "command": "next_field", "context":
		
			{ "key": "has_next_field", "operator": "equal", "operand": true }
		]
	},
	{ "keys": "tab"], "command": "commit_completion", "context":
		
			{ "key": "auto_complete_visible" },
			{ "key": "setting.auto_complete_commit_on_tab" }
		]
	},

See, all I did was copy all of the definitions for “tab” from the defaults and unbind the parts that would’ve been commented out. To be fair though, I’m still not sure what the wanted behaviour is…

0 Likes

#5

Dear community,

First of all I would like to thank you for taking the time to try and help me!

It’s kind of hard to explain what I want. So I made a video:

dropbox.com/s/wvfnri22jpex5 … nction.mov

Basically I want to keep tab have it’s normal function in all situations.
EXCEPT:
When I type in pinyin(chinese) or hiragana(japanese), and I get the box to select which characters. This selection is usually done with the “tab”. Which now is dysfunctional when typing asian languages in Sublime…

Anyone knows which changes I should make? I tried changing the user key bindings as Veedrac suggested, but alas…

Cheers mates! Thanks again!

0 Likes

#6

Well, I think I understand. Sorry, though, because I’m out of ideas.

What program does the popup for the Japanese?

0 Likes

#7

I think the problem is we are binding tab to something in general, so when you try to select characters, there is still some ST command trying to run. Even with a noop command, it’s still being grabbed before it reaches whatever is being used to do the character selection. I’m curious, what happens if you comment out the bindings in the default package (well technically override the file, but remove the tab entries). If you use the plugin I previously posted, it will save the file in the proper location to override the default package. You may need to restart the editor after making that change.

0 Likes