zoukankan      html  css  js  c++  java
  • Mathematica 定制快捷键

    和汉化的原理是一致的

    来源:http://stackoverflow.com/questions/5604837/keyboard-shortcut-to-un-comment-out-code-in-mathematica-7

    A keyboard shortcut to comment/uncomment out a piece of code is common in other programming IDE's for languages like Java, .Net. I find it a very useful technique when experimenting through trial and error to temporarily comment out and uncomment lines, words and parts of the code to find out what is and isn't working.

    I cannot find any such keyboard shortcut on the Mathematica front end in version 7. I know that it is possible to comment out code by selecting the code, right mouse click and select Un/Comment from the menu that appears but this is too slow while coding.

    I tried to access this using the menu key Menu on the keyboard but Mathematica frontend doesn't respond to or recognise this key unlike other applications, this could have allowed a key combination for commenting. Can someone else verify that this isn't unique to my machine and that the key isn't recognised by mathematica. I looked at this question and looked in the KeyEventTranslations.tr file but I don't think there is any way to create a shortcut to do this(?). Should I just live with it?

    Any other suggestions?

    (I have seen there is an Emacs version of mathematica, I have never tried Emacs or this Mma version and imagine that it would have this ability but would prefer not to go to the trouble and uncertainty of installing it. Also I would guess that the Wolfram Workbench could do this, but that may not be worth the investment just for this.)

    2 Answers

    You can install the shortcut in Mathematica 7.0.x if you are willing to edit the Mathematica system fileMenuSetup.tr. You can find it in the same location as the KeyEventTranslations.tr file (i.e. in the installation under "SystemFiles/FrontEnd/TextResources/platform"). In MenuSetup.tr, locate the following line under the definition of the Edit menu:

    MenuItem["Check &Balance", "Balance", MenuKey["B", Modifiers->{"Control", "Shift"}]],
    

    Immediately below that line, insert the following:

    MenuItem["Un/C&omment Selection", KernelExecute[FE`toggleComment[]], MenuKey["/", Modifiers->{"Command"}], MenuEvaluator -> Automatic, Method -> "Queued"],
    

    The Un/Comment Selection command is now available under the Edit menu, with the keyboard shortcutCmd-/ or Alt-/ depending on your platform -- just like in Mathematica 8 where this command comes pre-installed.

    Please take as read the usual disclaimers about hacking the Mathematica installation files -- no warranty is offered :)

    I do not know of any way to map this function to some shortcut involving the Menu key.

    Shortcut Key, No Menu

    The preceding steps mimic what Mathematica 8 does by installing a new menu item. If you prefer to leave the menus unchanged, then you can install the shortcut in KeyEventTranslations.tr instead. Add the following line:

    Item[KeyEvent["/", Modifiers->{Command}], KernelExecute[ToExpression["FE`toggleComment[]"]], MenuEvaluator -> Automatic, Method -> "Queued"]
    

    You'll need a comma on the end of that line if it is not the last item in the list.

  • 相关阅读:
    编码问题:python写入文件
    [ExtJS5学习笔记]第三十二节 sencha extjs 5与struts2的ajax交互配置
    PS 滤镜——Skewing
    [struts2学习笔记] 第六节 struts2依赖的jar包还有Could not find action or result 错误解决
    [linux RedHat]windows下使用putty远程连接linux 下载JDK和tomcat
    一个有趣的花环图案生成函数
    【翻译】针对多种设备定制Ext JS 5应用程序
    【翻译】Ext JS最新技巧——2015-1-2
    [ExtJS5学习笔记]第三十一节 sencha extjs 5使用cmd生成的工程部署到tomcat服务器
    PhotoShop 图像处理 算法 汇总
  • 原文地址:https://www.cnblogs.com/dabaopku/p/2012870.html
Copyright © 2011-2022 走看看