brittAnderson / Intro2Computing4Psychology

A guided introduction to computing tools useful for research in psychology - targeted to complete beginners
47 stars 159 forks source link

Running python code in emacs #22

Closed s296ahme closed 4 years ago

s296ahme commented 4 years ago

I’ve been able to combine both text and code on emacs but how do I make the code run? Is there a command to press or you do you just press enter? I find that when I copy Org Babel line and write the code (for example return(2+2)) it doesn’t return anything/give me the result. Am I doing something wrong?

bmmunds commented 4 years ago

After you set up the init.el file to evaluate a code block in .org file use Ctrl-C Ctrl-C. Hope that helps!

brittAnderson commented 4 years ago

Emacs has both a shortcut key stroke mode and also a command mode. You can invoke all available emacs commands with M-x somethingorother. Some of them will have an associated keystroke shortcut, in this case if your cursor is in a src block then M-x org-babel-execute-src-block will execute it. For most emacs systems that command is tied to C-c C-c.