Eclipse 智能引号 - 就像 Textmate 中一样

发布于 2024-08-11 02:36:06 字数 447 浏览 4 评论 0原文

星期五快乐 — 有谁知道 eclipse 是否有像 Textmate 这样的智能引号的概念。它的工作方式是选择一些单词并通过简单地点击 " 键来引用它们?我是这里的新手,所以要温柔。FWIW - 我在 Eclipse 中使用 pydev。

谢谢

重新措辞

假设我在屏幕上选择了一个单词或短语,我想简单地按“”键并将整个单词或短语用引号括起来。同样的情况也适用于各种键 - 比如 ([{"'`。

所以说我有以下代码

a = {}
a[keyword] = 1

现在(在 python 中)关键字应该用引号引起来。我应该能够双击(选择)关键字并简单地键入 < kbd>' 然后 viola 整个单词被引用。现在发生的事情是关键字被单引号替换......叹息..

谢谢。

Happy Friday — Does anyone know if eclipse has the notion of smart quotes like Textmate. The way it works is to select some words and quote them by simply hitting the " key? I'm a newbie here so be gentle. FWIW - I'm using pydev in Eclipse.

Thanks

Rephrase

What I am looking for is given I have a word or phrase selected on the screen, I would like to simply hit the '"' key and have the entire word or phrase enclosed by quotes. The same would apply to various keys — like ([{"'`.

So say I have the following code

a = {}
a[keyword] = 1

Now (in python) keyword should be in quotes. I should be able to double click (select) keyword and simply type the ' and then viola the whole word is quoted. Right now what happens is that keyword is replaced by a single quote... Sigh..

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

回心转意 2024-08-18 02:36:06

对于 Java 和 XML 文件,您可以在 Window / Preferences / Java / Editor / Templates 中创建新模板。模板文本可能如下所示:

"${word_selection}${}"${cursor}

然后您可以应用此模板,使用标准 Ctrl-空格键激活代码完成(可能需要按 2 或 3 次才能到达模板选择器),然后选择您的报价模板。

For Java and XML files you can create a new template in Window / Preferences / Java / Editor / Templates. The template text could look something like this:

"${word_selection}${}"${cursor}

Then you can apply this template activate code completion using a standard Ctrl-Space (may have to hit it 2 or 3 times to get to the template selector) and then select your quote template.

葬花如无物 2024-08-18 02:36:06

在最新的 PyDev 中,它应该完全按照您想要的方式工作(在 PyDev 2.2.3 中进行了测试 - 这实际上已经存在了一段时间)。

In the latest PyDev, it should work exactly as you want already (tested in PyDev 2.2.3 -- this was actually around for some time already).

这样的小城市 2024-08-18 02:36:06

我想我知道你在问什么,是不是...

如果你按 X 键,它会选择光标所在的当前单词?

如果这是一个问题,那么我不这么认为。
有很多可能的键绑定没有在 Eclipse 中设置。参见窗口>首选项>一般>键

更新:

抱歉,我认为 Eclipse 中没有执行此操作的操作。
可能存在一个可以附加到键绑定的插件,但我不知道有这样一个插件。

I think I know what you are asking, is it that...

if you press X-key it will select the current word that the cursor is in?

If that is the question, then I don't think so.
There are lots of possible keybinding that are not set in eclipse. See Window > Preferences > General > Keys

Update:

Sorry I don't think there is a action to do this in eclipse.
A plugin may exist that you can attach to a key binding, but I'm not aware of one.

别闹i 2024-08-18 02:36:06

您可以查看其中一个注释命令是如何工作的。例如,如果我选择 4 行代码,并且想要对所有代码进行行注释,我可以简单地选择它们,然后按 ctrl+/,所有选定的代码行都将被注释。

我是一个长期的短信用户,我错过了一些可怕的事情。我强迫自己放弃 Mac。我会在时间允许的情况下进行调查,但目前我不能继续陷入细微的调整。

-马特

You might check out how one of the comment commands work. For example, if I select say 4 lines of code and I want to line comment all of them I can simply select them then hit ctrl+/ and all of the selected lines of code will be commented.

I'm a long time textmate user and I'm missing it something terrible. I forced myself to make a hard switch away from my mac. I'll investigate as time permits but I can't keep getting stuck on minor tweaks at the moment.

-Matt

温柔少女心 2024-08-18 02:36:06

这是用 Autohotkey 编写的:

#NoEnv
SetWorkingDir %A_ScriptDir%
SendMode Input
#InstallKeybdHook
#UseHook On

(::
    if GetKeyState("ScrollLock","T")
    {
        sel := GetSelection(1)
        if sel
            PasteText("(" sel ")")
        else
            Send (
        sel := ""
    }
    else
        Send (
Return

"::
    if GetKeyState("ScrollLock","T")
    {
        sel := GetSelection(1)
        if sel
            PasteText("""" sel """")
        else
            Send "
        sel := ""
    }
    else
        Send "
Return

'::
    if GetKeyState("ScrollLock","T")
    {
        sel := GetSelection(1)
        if sel
            PasteText("'" sel "'")
        else
            Send '
        sel := ""
    }
    else
        Send '
Return

{::
    if GetKeyState("ScrollLock","T")
    {
        sel := GetSelection(1)
        if sel
            PasteText("{" sel "}")
        else
            Send {{}}
        sel := ""
    }
    else
        SendRaw {
Return

[::
    if GetKeyState("ScrollLock","T")
    {
        sel := GetSelection(1)
        if sel
            PasteText("[" sel "]")
        else
            Send [
        sel := ""
    }
    else
        Send [
Return

<::
    if GetKeyState("ScrollLock","T")
    {
        sel := GetSelection(1)
        if sel
            PasteText("<" sel ">")
        else
            Send <
        sel := ""
    }
    else
        Send <
Return


GetSelection(wait = "")
{
    ClipBack := ClipboardAll
    Clipboard := ""
    Send ^c
    if wait
        ClipWait 0.05
    Selection := Clipboard
    Clipboard := ClipBack
    Return Selection
}

安装 Autohotkey 后,将此代码保存到文本文件中,将扩展名重命名为 .ahk 并运行它。它需要打开滚动锁才能使代码正常工作。

此代码从 http://www.autohotkey.net/~Vifon/ 修改为:

  1. 包括' 和 <
  2. 当未选择文本时,写 ', ", <, {, [, ( 而不是 '', "", <>, {}, [], ()。

Here is one written in Autohotkey:

#NoEnv
SetWorkingDir %A_ScriptDir%
SendMode Input
#InstallKeybdHook
#UseHook On

(::
    if GetKeyState("ScrollLock","T")
    {
        sel := GetSelection(1)
        if sel
            PasteText("(" sel ")")
        else
            Send (
        sel := ""
    }
    else
        Send (
Return

"::
    if GetKeyState("ScrollLock","T")
    {
        sel := GetSelection(1)
        if sel
            PasteText("""" sel """")
        else
            Send "
        sel := ""
    }
    else
        Send "
Return

'::
    if GetKeyState("ScrollLock","T")
    {
        sel := GetSelection(1)
        if sel
            PasteText("'" sel "'")
        else
            Send '
        sel := ""
    }
    else
        Send '
Return

{::
    if GetKeyState("ScrollLock","T")
    {
        sel := GetSelection(1)
        if sel
            PasteText("{" sel "}")
        else
            Send {{}}
        sel := ""
    }
    else
        SendRaw {
Return

[::
    if GetKeyState("ScrollLock","T")
    {
        sel := GetSelection(1)
        if sel
            PasteText("[" sel "]")
        else
            Send [
        sel := ""
    }
    else
        Send [
Return

<::
    if GetKeyState("ScrollLock","T")
    {
        sel := GetSelection(1)
        if sel
            PasteText("<" sel ">")
        else
            Send <
        sel := ""
    }
    else
        Send <
Return


GetSelection(wait = "")
{
    ClipBack := ClipboardAll
    Clipboard := ""
    Send ^c
    if wait
        ClipWait 0.05
    Selection := Clipboard
    Clipboard := ClipBack
    Return Selection
}

After installing Autohotkey, save this code to a text file, rename the extension to .ahk and run it. It requires the Scroll Lock to be turned on for the code to work.

This code is modified from http://www.autohotkey.net/~Vifon/ to:

  1. Include ' and <
  2. Write ', ", <, {, [, ( instead of '', "", <>, {}, [], () when no text is selected.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文