在Mathematica中将[[和]]用于Part有办法吗? [英] Is there a way around using [[ and ]] for Part in Mathematica?

查看:111
本文介绍了在Mathematica中将[[和]]用于Part有办法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以避免必须执行⋮[[⋮来获得Part那些漂亮的括号的方法?

运行函数或定义后,是否可以自动完成此操作?

解决方案

我在/Applications/Mathematica.app/SystemFiles/FrontEnd/TextResources/Macintosh/KeyEventTranslations.tr中有以下新增内容,可让我输入带有组合键的方括号.您可以通过修改文件(在OS上的任何位置)来执行相同的操作.我首先从 Szabolcs's 网站

对于Macintosh:"Command" =命令键,"Option" =选项键

对于X11:命令" = Mod1,选项" = Mod2

对于Windows:命令" = Alt,选项" = Alt

在上述文件的EventTranslations[{之后插入以下内容.

(* Custom keyboard shortcuts *)
    Item[KeyEvent["[", Modifiers -> {Control}],
        FrontEndExecute[{
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "\[LeftDoubleBracket]", After]
        }]],
    Item[KeyEvent["]", Modifiers -> {Control}],
        FrontEndExecute[{
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "\[RightDoubleBracket]", After]
        }]], 
    Item[KeyEvent["]", Modifiers -> {Control, Command}],
        FrontEndExecute[{
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "\[LeftDoubleBracket]", After],
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "\[RightDoubleBracket]", Before]
        }]], 


您不是唯一受此困扰的人. 这里是我的尝试,目的是避免拉伸到通过将 Caps lock 映射到 Esc Esc .向导先生还拥有夫妇 .com/questions/5461688/如何将[[转换为的问题. /p>

Is there a way to avoid having to do ⋮[[⋮ to obtain those great looking brackets for Part?

Is there a way for this to be done automatically after you ran a function or a definition ?

解决方案

I have the following addition in /Applications/Mathematica.app/SystemFiles/FrontEnd/TextResources/Macintosh/KeyEventTranslations.tr which lets me enter double brackets with key combinations. You can do the same by modifying the file (where ever it is on your OS). I first learnt of this from Szabolcs's website here. He has other mathematica related stuff there that might be of help to you.

The commands added are:

  • with Ctrl+[
  • with Ctrl+]
  • 〚〛 with Ctrl+Alt+]

Equivalents, as listed in the KeyEventTranslations.tr file are:

Modifiers can be "Shift", "Control", "Command", "Option"

For Macintosh: "Command" = Command Key, "Option" = Option Key

For X11: "Command" = Mod1, "Option" = Mod2

For Windows: "Command" = Alt, "Option" = Alt

Insert the following after EventTranslations[{ in the above file.

(* Custom keyboard shortcuts *)
    Item[KeyEvent["[", Modifiers -> {Control}],
        FrontEndExecute[{
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "\[LeftDoubleBracket]", After]
        }]],
    Item[KeyEvent["]", Modifiers -> {Control}],
        FrontEndExecute[{
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "\[RightDoubleBracket]", After]
        }]], 
    Item[KeyEvent["]", Modifiers -> {Control, Command}],
        FrontEndExecute[{
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "\[LeftDoubleBracket]", After],
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "\[RightDoubleBracket]", Before]
        }]], 


You're not the only one who's peeved by it. Here's my attempt to avoid having to stretch to hit Esc by mapping Caps lock to Esc. Mr. Wizard also had a couple of questions related to conversion of [[ to .

这篇关于在Mathematica中将[[和]]用于Part有办法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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