how to send code to ipython from vim - 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.

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.

ballooneval in terminal vim

I've been using pyclewn for debugging in vim. It works quite well on gvim with ballooneval to show the values of variables but the problem is I'm mostly using vim in a terminal so that I can't use the balloon feature.
I have found this but it looks abondoned already and I couldn't make it work as there's no installation instructions. Does anyone know a way to use ballooneval in terminal vim?
From documentation:
m +balloon_eval balloon-eval support. Included when compiling with
supported GUI (Motif, GTK, GUI) and either
Netbeans/Sun Workshop integration or +eval feature.
It's not quite clear though, whether this imply that terminal mode does not support ballooneval at all (or it's available in terminal mode when GUI is compiled in), but there's no clues to do that in the documentation.
So: it's highly unlikely that you can use ballooneval in the terminal mode without messing with the Vim sources.
Starting from Vim version 8.0.1309 there is support for balloon in terminal. Seems to be work in progress though.
You can find a usage example in the following issue:
https://github.com/vim/vim/issues/2481

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

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.

Running R inside a buffer in Vim

I have used Stata and gVim on Windows for a while now. Recently I have switched to Linux, and I am planning to also change from Stata to R.
A friend of mine is using R and Emacs ESS which seems to work perfect, however i'd rather like to keep using vim. I have installed the vim-r-plugin2, however, i can only send code to a seperate terminal running R. I would much rather split my screen into a buffer running R and one buffer with my .R file, and then send code from one to the other. With ESS in Emacs this seems to work, you can run a terminal/R in a buffer without a problem. I haven't found a way to make this work. The R plugin for vim uses screen, and the only way to open a buffer running a shell I could find is the Conque Shell plugin.
I know that unlike Emacs, Vim is designed to be a simple text editor. However, having R run in a buffer seems just so much more practical.
I hope my problem is understandable, please bear with me I only recently switched to Linux and know virtually nothing about programming besides statistics. Thanks!
If you do not need to input unicode, you can consider using ConqueShell plugin.
In the meanwhile, the 'evil' (extensible vi emulation layer) mode has matured. This is a vim emulator running in Emacs and works quite well for me.
Another option, and forgive me for pointing you back to EMACS,
viper-mode
http://www.informatik.uni-hamburg.de/RZ/software/emacs/viper/viper_3.html
It's an EMACS mode that makes EMACS feel more like Vim, while giving you full access to the wonderful, mind-boggling complexity of EMACS if you ever want it.

Resources