Interact wtih the terminal, or REPL(Read-Eval-Print Loop), in vim 8.1 especially for Python programming. Theoretically, it can also be used for bash and other languages. The main feature is sending the commands to the console and execute without considering the indent problem !
Advantages compared with other similar plugins
- installation and configuration are so easy without any effort.
- support multiple languages, including
Python,bash - support virtual environment of
Pythonnaturally, which can be verified by following steps- activate one
venv, - open a
*.pyusingvim - type
:terminalto open a built-in terminal - type
pip show numpy(or other packages), which can list the location of package. Using the location to tell whether it's in the virtual environment or not
- activate one
Copy the content in vimrc to the vim config file, eg~/.vimrc.
After the installation, there are two ways to open the ipython console:
- open the console with
--no-autoindent, for example
:terminal ipython3 --no-autoindentOtherwise this plugin can't work properly!
- open the console with built-in command
:Ip3which is controlled by the following config
command Ip3 terminal ipython3 --no-autoindent
command P3 terminal python3So, you can change the alias by yourself
The short cut is <leader>s.
- in
normal mode: typing<leader>swill send the current line to the console and execute - in
visual mode: typing<leader>swill send the selected lines to the console and execute - in
visual mode: typing<leader>jwill just send the selected content, which can be a few words in one line or several lines, to the console without executing
example
send commands with indent
bash command

- Fix the blank lines issue when sending code blocks into
Pythonconsole. Detail can be refered from Copy-paste into Python interactive interpreter and indentation, Python interactive interpreter has problems with blank lines when I paste in a script [duplicate], Blank line rule at interactive prompt and How to automatically insert spaces to make empty lines in Python files indent? - Fix the indent issue in
ipython: can't send long code blocks toipythonconsole. The reason is explained in jpalardy/vim-slime. The magic function inipythoncan't reach the target, which is explained in Turn off IPython autoindent on submit #71. The way to solve the issue is : disable the autoindent inipython - Add new feature : just sending the selected content to the console without executing

