Sublime Forum

Is it possible switch the function of keys?

#1

I want [enter] to do the function of [down arrow key] and [shift+enter] to do what a normal enter does.

0 Likes

#2

Not sure why you would require such a functionality but it’s quite simple. Create a new .sublime-keymap file in your Users directory, for the sake of brevity, let it be Default.sublime-keymap.

You now have to paste in the following into the above file:

[
	{ "keys": ["shift+enter"], "command": "commit_completion", "context":
		[
			{ "key": "auto_complete_visible" },
			{ "key": "setting.auto_complete_commit_on_tab", "operand": false }
		]
	},
	{ "keys": ["enter"], "command": "move", "args": {"by": "lines", "forward": true} },
]

Basically, what I did is inspect the Default/Default (Windows).sublime-keymap and found what the json is for enter and down and copied those into the Users/Default.sublime-keymap and changed the keys to the one you desire. Remember that the down will function normally since it’s not overriden.

2 Likes

#3

Thanks man, shit works perfect. Yeah I have a habit to use enter to jump to next code line while going over the complete code, honestly didn’t expected this was possible.

0 Likes