粘贴Mathematica代码,以便将其分成单独的输入单元格 [英] Paste Mathematica code so that's it's broken into separate input cells
问题描述
我经常将Mathematica代码从网站(例如SO)复制到笔记本上.该代码通常粘贴为单个输入单元格.我正在寻找一种简单的方法将其粘贴为几个输入单元格,以便进行逐步评估.
I often copy Mathematica code from websites (such as SO) to a notebook. The code usually gets pasted as a single input cell. I'm looking for a simple way to paste it as several input cells for convenient step-by-step evaluation.
例如,
a = 2;
f[x_] := x^a
Plot[f[x], {x,0,2}]
理想情况下将粘贴为两个输入单元格.最好还保留手动格式设置(即原始换行符)(默认粘贴不是这种情况).
would ideally paste as two input cells. Manual formatting (i.e. the original newlines) should preferably also be preserved (this is not the case with default pasting).
通常,如果选择所有输入单元格(按ALT键并单击),然后将它们复制到文本编辑器中,然后将结果文本复制回笔记本中,则应该获得与复制的原始单元格相当的效果.
Generally, if one selects all input cells (ALT-click), copies them into a text editor, then copies the resulting text back into a notebook, one should get a close equivalent of the original cells that were copied.
推荐答案
或者....您只需按 Ctrl + Shift + D ,此时您想将单个单元格拆分为2个单独的单元格.有时将多个操作分组到一个单元中(或者最好不要将它们分割成一个单元)是有利的.要撤消此类拆分,请选择两个单元格(或根据需要选择两个以上的单元格),然后单击 Ctrl + Shift + M 进行合并他们合而为一.
Or.... you can just Hit Ctrl+Shift+D at the point where you'd like to split your singe cell into 2 separate cells. Some times it's advantageous to group multiple operations into a single cell (or rather not split them to begin with). To undo such a split, select both cells (or more than 2 if you'd like) and click Ctrl+Shift+M to merge them into one.
这篇关于粘贴Mathematica代码,以便将其分成单独的输入单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!