如何禁用/覆盖自动完成的回车键? [英] How to disable/override the enter key for autocomplete?

查看:46
本文介绍了如何禁用/覆盖自动完成的回车键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Sublime Text 3 中,我想禁用 enter 键以从自动完成下拉列表中选择一个项目,并且只允许 tab 键这样做.

In Sublime Text 3, I want to disable the enter key to select an item from the autocomplete drop down, and only allow the tab key to do so.

我在内置的 Default (OSX).sublime-keymap 文件中找到了这个部分:

I found this section in the inbuilt Default (OSX).sublime-keymap file:

{ "keys": ["enter"], "command": "commit_completion", "context":
    [
        { "key": "auto_complete_visible" },
        { "key": "setting.auto_complete_commit_on_tab", "operand": false }
    ]
},

似乎如果我从 enter 的配置中删除它,将不会在下拉列表中选择一个项目.不幸的是,不建议更改此文件,而只能在我的 User 文件中覆盖它.我认为我实际上无法在不修改 .app 内容的情况下对其进行编辑.

It seems that if I remove this from the config that enter will not select an item in the drop down. Unfortunately it is not recommended to change this file, and only to override it in my User files. I don't think I actually can edit it without modifying the .app contents.

我试图通过删除不同的部分来覆盖它,还删除了除 "keys": ["enter"] 之外的所有内容,但似乎没有任何效果.

I tried to override it by removing different sections, and also remove everything except "keys": ["enter"], but nothing seems to work.

如果不修改内置的 Default (OSX).sublime-keymap 和只有 User/Default (OSX).sublime-keymap 文件,我将如何实现这一目标?

How would I go about achieving this without modifying the inbuilt Default (OSX).sublime-keymap and only the User/Default (OSX).sublime-keymap file?

推荐答案

我从未使用过 Sublime Text 3, 但我认为自 Sublime Text 2 以来以下内容没有改变.

I have never used Sublime Text 3, but I don't think the following has changed since Sublime Text 2.

你想要实现的其实是 Sublime Text 中的一个标准功能.你只需要打开它.

What you want to achieve is actually a standard feature in Sublime Text. You just have to turn it on.

您引用的代码中的这一行...

This line from your the code you quoted …

{ "key": "setting.auto_complete_commit_on_tab", "operand": false }

... 表示仅当名为 'auto_complete_commit_on_tab' 的设置设置为 false 时才执行命令".所以只需打开该设置.

… means "only execute the command if the setting called 'auto_complete_commit_on_tab' is set to false". So simply turn on that setting.

在 Default/Preferences.sublime-settings 中:

In Default/Preferences.sublime-settings:

// By default, auto complete will commit the current completion on enter.
// This setting can be used to make it complete on tab instead.
// Completing on tab is generally a superior option, as it removes
// ambiguity between committing the completion and inserting a newline.
"auto_complete_commit_on_tab": false,

"auto_complete_commit_on_tab": true 放在 User/Preferences.sublime-settings 中.可以通过首选项"菜单访问上述两个文件.

Put "auto_complete_commit_on_tab": true in User/Preferences.sublime-settings. Both mentioned files can be accessed via the Preferences menu.

这篇关于如何禁用/覆盖自动完成的回车键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆