start gvim without it taking focus from the terminal that started it - vim

I would really like to find a way to start gvim without the terminal losing focus.
I found a way to use gvim to display code when debugging in dbx.
Gvim as dbx frontend
This works great but it causes gvim to steal the focus every time it hits a breakpoint or changes line.
I am pretty sure I could adapt a terminal keeping focus to work inside dbx.
I am running solaris on a sparc processor.
How can I start gvim without it taking focus from the terminal that started it?

If you're a KDE user, you can start gvim with the kstart command. The kstart program has extensive options for controlling the behavior of the program you're starting. The --onbottom option might accomplish what you're trying to do.

Related

Vim freezes consistently for several reasons

Vim freezes and I see a key sign as I have circled in the picture below when doing the following things
When opening a new file in terminal vim, especially a cpp file.
When terminal vim is left idle for a few seconds
When I click outside the terminal window and then click back into terminal vim.
Ctrl-c unfreezes vim.
This is 100% reproducible on terminal vim, and not reproducible at all on MacVim. I am on MacOS.
When vim is launched from MacOS terminal app (and not iterm), I get a blinking key, and vim freezes just the same.
Please help me unfreeze vim, I've been digging for a while and not come up with anything.
Maybe one of your plugins/custom config is playing the devil here. Would you try and see if the same problem exists while running vim without any custom configurations, like :
vim --clean
if it works as expected, then you should definitely take a look into your .vimrc and start cleaning it.
If the error persists even after running vim clean, then what i would have done would be to check if the shell configs (like .bashrc,.bash_profile etc) for unwanted settings that directly/indirectly affect the working of vim.
As a last resort to avoid confusion, you should also try to debug whether you have given any custom setting for your terminal emulator. Try reinstalling your terminal emulator or run it clean and see if it helps.

Using console as tab

I have several cpp source files in tabs in vim. I would like to have another tab with command prompt in order to run make. I open net tab , run sh and now I have console. But how to move from this console to other tabs? If I press ctrl+page up I have garbage in console and no tab change. How to move to another text tab when staying in console tab?
As I said, vim 8 or neovim both have an terminal emulator in it.
Since you are using vim 7 here are some other ways:
Tmux as #wizzup mentioned is perfect for this use-case. I think it is the most used Terminal-Multiplexer and extremly mighty. It is complex in comparison but since you are using vim, a steep learning curve should not be a killer point. However there are a few cavehats but you will find thousands of articles to solve them.
GNU Screen is an alternative to tmux, I have no experience with it, but should be usable pretty good with vim too.
With them you can use something like this Plugin which allows you to use the terminal in vim itself. However I haven't tested it but it seems to be rather groomed.

running x11 on cygwin, all terminals stuck at one corner

I am trying to run x11 on cygwin, mainly to run xfig utility, and I am facing a problem.
When I run xinit to start x11, I get a big popup window with one terminal open. But I am unable to open any other terminals in it. To be more specific, when I run "xterm &" in it, a new terminal opens up but it sits on top of the old terminal, and there is no way I can move this window, so the old terminal is as good as useless to me, till I kill the new terminal.
I also tried running "xwin". There a big window popped up, but it does not contain any terminal, and I cant open any terminal, whether by left or right clicking.
I also tried running "startx". A big window opens up but gets killed automatically after a few seconds.
How can I use x11 effectively on cygwin? As of now, I can use with "xinit", but with only one terminal.
The proper mode to start the Xserver on cygwin is to use starxwin.
From its manual:
The startxwin script is a front end to xinit(1) that provides a
some what nicer user interface for running a single session of the X Window
System in multiwindow mode. It is often run with no arguments.
To move windows around, you need to have a window manager running. You can start this either from the xterm, by passing the name of the window manager as an argument to startx, or by starting it from your X11 startup configuration (memory says that would be ".xinitrc" in your home directory on most unix boxes, but I am not sure if that's true on Windows using Cygwin). The .xinitrc file is "just" a shell-script, with the end of the script indicating "X should shut the server down now" (see example at the end).
There are many possible window managers, including fvwm2 (which according to your comment, you managed to find on your own). A full list of X11 window managers is probably too long to fit in this answer (there are many, there are new ones popping up, and old ones going out of maintenance on an ongoing basis). Some of the not entirely uncommon ones are fvwm2 (already mentioned), cinnamon, twm, ctwm, ratpoison, ... For a more up-to-date list, ask your favourite search engine for "list of X11 window managers".
Example .xinitrc file:
# This is an example .xinitrc file, starting first an xterm,
# then a window manager. As the X server terminates when this script
# does, we start the X terminal in the background, but the window
# manager in the foreground, so that "WM exists" signals "X server shuts down"
xterm &
fvwm2

how to send code to ipython from vim

Frankly speaking, I want an integration of vim and IPython, and I know there is such a great vim plugin vim-ipython, I indeed tried this, but it doesn't work out on Windows7 and tried to make it work (non-trivial thing, little documentation about it, failed and gave up).
Now I want to know if it's possible to connect a running ipython kernel from vim and send code to it?
I had something very similar running at some point.
It's not a clean solution in a sense that there is no Vim/IPython integration (as far as I know given the way Vim core is written such integration is unlikely to happen) but it did work.
Install tmux terminal multiplexer (http://tmux.sourceforge.net/)
Launch two tmux panes inside the terminal, one for Vim, one for IPython
Install vim-slime plugin, configure it to use tmux (http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/, https://github.com/jpalardy/vim-slime).
Now, whenever you'll select some code in Vim and press the slime shortcut (C-c C-c by default) it will be sent to the IPython session and executed.
I think this will get the behavior you want.
It's also agnostic to IPython and can be used with any REPL environment.

alt-tab like functionality when using terminal?

When working in GUI we do alt-tab (or cmd-tab in mac) to switch between multiple programs, for example I am writing a text file in a text editor and then I do alt-tab to switch to already running browser to google up something then I alt-tab again to come back to keep editing.
How do you perform such "switch between" programs in command line interface - for example working with a ssh command line shell?
EDIT: I forgot to mention it, I am using ssh to connect to my university's server, and they don't have screen & tmux installed, and my account have no right to install any new apps... Is there any built-in functionality to perform this task, or any work around? For exmaple can I "minimize" running proggram and come back to regular shell interface, do some work, then display the "minimized" process again?
Another workaround: use the shell's job control, eg if you're editing a file, CTRL-z pauses the editor and brings you back to the shell, where you can compile, see manpages, browse the web or whatever -- and of course you can background the browser or anything else.
Screen command offers the ability to detach a long running process (or program, or shell-script) from a session and then attach it back at a later time.
As a crude workaround, run multiple terminal windows on your computer, and alt-tab between them.
Incidentally, at the Linux console, you can switch virtual terminals with ctrl+alt+F for at least F1 through F6, commonly F8 or more (depends on how the distro sets them up). Not your case, I know, but in case future visitors should benefit.
If you are comfortable in Emacs, it allows you to run multiple independent ansi-term buffers.
You can also use "GNU screen" to emulate multiple terminals in one terminal.

Resources