本文介绍了Sublime 3-为功能Goto Definition设置键映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Eclipse样式快捷方式 + 以打开函数/方法. Sublime Text 3已经具有称为goto_definition的功能,但已绑定到.

I want to create an Eclipse style shortcut + to open the function/method. Sublime Text 3 has already this function called goto_definition but it is bound to .

但是我不确定如何创建此绑定.我在此处中查找了文档,但这太复杂了.您可以通过这种简单的键绑定帮助我吗?

But I'm not sure how to create this binding. I looked here for documentation but it was too complex. Can you one help me out with this simple key binding?

在这篇文章之后,我被告知要这样做: http://webtempest.com/better-definition-navigation-in-sublime-text-3/

Following this article I was told to do this: http://webtempest.com/better-definition-navigation-in-sublime-text-3/

[
    {
        "button": "button1", 
        "count": 1, 
        "modifiers": ["super", "shift"],
        "press_command": "drag_select",
        "command": "goto_definition"
    }
]

这似乎不起作用, + + 不会执行任何操作.

This doesn't seem to work, ++ executes nothing.

推荐答案

对于其他想要设置Eclipse样式goto定义的人,您需要在Sublime User文件夹中创建.sublime-mousemap文件.

For anyone else who wants to set Eclipse style goto definition, you need to create .sublime-mousemap file in Sublime User folder.

Windows-在%appdata%\Sublime Text 3\Packages\User

Windows - create Default (Windows).sublime-mousemap in %appdata%\Sublime Text 3\Packages\User

Linux-在~/.config/sublime-text-3/Packages/User

Mac-在~/Library/Application Support/Sublime Text 3/Packages/User

现在打开该文件,并将以下配置放入其中

Now open that file and put the following configuration inside

[
    {
        "button": "button1", 
        "count": 1, 
        "modifiers": ["ctrl"],
        "press_command": "drag_select",
        "command": "goto_definition"
    }
]

您可以根据需要更改modifiers键.

You can change modifiers key as you like.

由于Windows和Linux上的-button1用于多项选择,因此,如果要使用第二个修饰键,例如,则可能是个好主意两个功能:

Since -button1 on Windows and Linux is used for multiple selections, adding a second modifier key like might be a good idea if you want to use both features:

[
    {
        "button": "button1", 
        "count": 1, 
        "modifiers": ["ctrl", "alt"],
        "press_command": "drag_select",
        "command": "goto_definition"
    }
]

或者,您可以单独使用鼠标右键(button2)和,而不会干扰任何内置函数.

Alternatively, you could use the right mouse button (button2) with alone, and not interfere with any built-in functions.

这篇关于Sublime 3-为功能Goto Definition设置键映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 04:50