I've been opening emacs from the terminal but every time I want to compile my c program, i have to quit emacs first, compile it on terminal, then re-open emacs afterward again to edit some more.
Is there a simpler way to do this so I can keep emacs open while also compiling stuff on terminal?
I know this has something to do with entering shell mode but I'm not too familiar with that or editing the init file as im really new to emacs and still trying to get the hang of it
Any help is appreciated, thanks!
To compile your program while inside Emacs, type
M-x compile and enter the compilation command. As a bonus, any errors or warnings in the output become links to the corresponding line in the source code.
Once your program is compiled, there are a few different ways to run it. If it's a non-interactive program, you may find that
M-! (for running a shell command, waiting for it to finish, and displaying its output in a buffer) is sufficient. Otherwise, you may want to run a shell inside Emacs. You can do that with
M-x eshell. (Some people prefer
M-x shell; try both and see what you like.)
Alternatively, if you want to temporarily leave Emacs and go back to the terminal, you can type
C-z to put Emacs in the background. To go back from the shell to Emacs, type
fg (for "foreground"). To check whether Emacs is currently running in the background, type