How to compile while gedit is open in gnome? - gnome

I am using gcc to compile c code that I am writing in gedit. My problem is that while my .c file is open in gedit, any command I type into my terminal just hangs until gedit is closed. Obviously it is quite cumbersome editing, saving, closing, running, reopening etc. I was wondering how I can have gedit open while compiling so I don't have to close it every time?

Are you launching gedit from that same terminal? This may be a stupid answer, but make sure you're launching gedit with an ampersand, i.e. using the command line gedit &. Without the &, that terminal window won't let you execute additional commands until gedit closes. With the &, gedit runs in the background. Gcc should have no problem compiling a file that's open in an editor. But remember that only the most recent saved version will be seen by gedit, so save your work before trying to compile.

run gedit in background. Like
gedit yourfile &

Related

open vim file in new unix terminal

How to open existing vim file from unix shell (bash) in new terminal (not in same/new tab of existing terminal) on local machine ?
Also is there any way to split file on new terminal (not in same/new tab of existing terminal) from inside vim ?
How to open a new terminal is platform dependent; This doesn't really have a whole lot to do with vim itself.
For example, if you're using GNOME you could do this by running gnome-terminal -e "vim $filename" & disown. Look up the documentation for the terminal emulator you're using to find out how to launch a new terminal and execute commands in it.
Another (IMHO much better) solution is to simply use GVim for situations like these, unless you have a very good reason to run vim in the terminal (if you're running this over ssh this won't work anyway, in that case you're better off using a terminal multiplexer like screen or tmux).
PS: bash isn't a terminal (emulator); bash is a shell. If you just run a new instance of bash it'll run in the same terminal, which is not what you want here.
Try this:
vim [your file]
If this isn't working for you, make sure you have it installed with:
sudo apt-get install vim
If you're already IN vim do
:edit [your file]

Linux: Gedit won't run in foreground

If I run gedit in the Linux terminal ($ gedit) it opens as a background job; which is not what I'm after at the moment.
Other programs (such as emacs) run in the foreground with commands like ($ emacs) and only run in the background if I've specified it via something like ($ emacs &).
I've tried searching for a solution but almost everything is about the opposite (trying/struggling to get things to run in the background).
Any ideas?
As it works for me: I run gedit /tmp/file.txt for the first time and it runs in the foreground. Then I open another terminal tab and run gedit /tmp/file2.txt while Gedit is still open — the second command instructs running instance of Gedit to open second tab and exits immediately. Gedit is still in the foreground in the first terminal tab.
According to gedit help, it has an option
-w, --wait Open files and block process until files are closed
If in the second terminal tab I run gedit --wait /tmp/file3.txt, then it opens a new tab in the existing Gedit window but the command stays in the foreground until I close that file tab.
Just in case: it was tested under KDE, Ubuntu 16.04, gedit version is 3.18.3

Freeing Terminal While Using gVim

Is there a way that I can free my terminal from running the gVim process w/o quitting gVim so that I can continue to use the terminal? I'd like to be able to
do something similar to what I do with emacs. With emacs I can either use the emacs [file] command to have the process run through the terminal, or I can use the runemacs [file] command to keep the terminal free.
I start gVim with the command:
gvim [file]
and then the terminal hangs until I :quit gVim. When I searched for an answer to this question on the web, people advised that the best thing to do was to use ctrl-z to suspend the vim process and then use fg to return. However, this fails to work for me in both command line and gVim mode. I'm using Git Bash for my terminal on Windows 7.
You could run gvim in background as any other process:
gvim [file] &
After executing this command you receive a message indicating the pid of the new process. When you end it you should receive a similar message on that shell.
Edit:
The ctrl-z/fg problem is probably related to windows. This question states that GitBash would create a new shell instead of returning to the current one, so it probably doesn't work as in Linux. A possible solution would be to run your commands from gVim, either calling the shell through :! on mappings, or plugins/commands (fugitive for git, :py or some plugin for python interpreter, etc).

Run program as a (linux style) foreground terminal process on windows?

does anyone know how to produce a similar result?(essentially tying the windows terminal to the open program)
For example, when you run "emacs" in bash (or another linux terminal) it will produce an output into the open terminal until the program is terminated (or silenced with emacs &)
I want to be able to reproduce this effect on windows, but have no idea how, running start(and similar commands) will only run the program in a new window, with a hidden command line, detached from the cmd line process.
You need the /B flag:
start /B myprogram
(Of course, this will only work with programs that actually use the console. If the program doesn't generate console output, this won't magically make it do so.)
You can do that by first installing Cygwin and then running emacs from Cygwin.
Cygwin is a collection of tools which provide functionality similar to a Linux distribution on Windows.
try typing edit into a windows command shell, it's actually a better program than notepad. there are versions of vi, emacs, for windows and dos, you could try any of them.
ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/
http://www.vim.org/download.php#pc

Linux gedit and the terminal

Whenever I am using gedit to write code I can access either gedit or the terminal but not both. For example, when I type gedit hello.c linux brings up the file hello.c inside gedit. Now, while gedit is still displaying hello.c I cannot type anything into the terminal without closing hello.c in gedit.
How can I get around this so that I may actively use both the terminal and gedit simultaneously?
Thanks
type gedit hello.c &
or if you have already typed it without the ampersand press Ctrl + Z to send it to background, and type bg to enable gedit as David pointed out.
if you already started gedit, press CTRL + Z, then type
bg && disown
dis will run gedit in background and disown it from the terminal (so gedit wont die if you close the terminal)

Resources