{"id":13478628,"url":"https://github.com/hanschen/vim-ipython-cell","last_synced_at":"2025-03-27T07:31:26.210Z","repository":{"id":41507004,"uuid":"187610660","full_name":"hanschen/vim-ipython-cell","owner":"hanschen","description":"Seamlessly run Python code in IPython from Vim","archived":false,"fork":false,"pushed_at":"2023-05-22T14:07:50.000Z","size":211,"stargazers_count":335,"open_issues_count":1,"forks_count":18,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-30T11:42:22.259Z","etag":null,"topics":["python","repl","vim"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hanschen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-05-20T09:33:41.000Z","updated_at":"2024-10-20T03:04:14.000Z","dependencies_parsed_at":"2023-10-20T21:11:09.509Z","dependency_job_id":null,"html_url":"https://github.com/hanschen/vim-ipython-cell","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanschen%2Fvim-ipython-cell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanschen%2Fvim-ipython-cell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanschen%2Fvim-ipython-cell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanschen%2Fvim-ipython-cell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanschen","download_url":"https://codeload.github.com/hanschen/vim-ipython-cell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245802611,"owners_count":20674708,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","repl","vim"],"created_at":"2024-07-31T16:01:59.588Z","updated_at":"2025-03-27T07:31:23.907Z","avatar_url":"https://github.com/hanschen.png","language":"Python","readme":"ipython-cell\n============\n\nSeamlessly run Python code from Vim in IPython, including executing individual\ncode cells similar to Jupyter notebooks and MATLAB.\nThis plugin also supports [other languages and REPLs](#other-repls) such as\nJulia.\n\nipython-cell is especially suited for data exploration and visualization using\nPython. You can for example define a code cell that loads your input data, and\nanother code cell to visualize the data. This plugin allows you to change and\nre-run the visualization part of your code without having to reload the data\neach time.\n\nThe major difference between ipython-cell and other plugins (such as vim-slime\nand nvim-ipy) is that this plugin has 'non-verbose' commands that do not show\nthe code that is run. This makes it easier to read the output in IPython.\nAdditionally, ipython-cell provides some convenience commands to jump between\ncells and to work with IPython, see [Commands](#commands) below.\n\n**New in 0.5:**\nipython-cell now defaults to sending `i` + Ctrl-C (instead of Ctrl-U) to clear\nthe prompt before running cells and other commands. See Issue [#35][i35] for\nmore information.\n\n[i35]: https://github.com/hanschen/vim-ipython-cell/issues/35\n\n\nDemo\n----\n\n![Demo animation](../assets/ipython-cell-demo.gif?raw=true)\n\n\nRequirements\n------------\n\nipython-cell requires Vim or Neovim to be compiled with Python 2 or Python 3\nsupport (`+python` or `+python3` when running `vim --version`). If both Python\nversions are found, the plugin will prefer Python 3.\n\nipython-cell depends on [vim-slime] to send the code to IPython, see\n[Installation](#installation) instructions below.\n\nAdditionally, the 'non-verbose' cell execution feature requires Tkinter to be\ninstalled and either `+clipboard` support in Vim (see `vim --version`), or an\nexternal [clipboard program](#supported-clipboard-programs) to be installed.\nThere is also a verbose version of the cell execution feature that does not\nrequire Tkinter or clipboard support, see [Usage](#usage).\n\n[vim-slime]: https://github.com/jpalardy/vim-slime\n\n\nInstallation\n------------\n\nIt is easiest to install ipython-cell using a plugin manager (I personally\nrecommend [vim-plug]). See respective plugin manager's documentation for more\ninformation about how to install plugins.\n\n\n### [vim-plug]\n\n~~~vim\nPlug 'jpalardy/vim-slime', { 'for': 'python' }\nPlug 'hanschen/vim-ipython-cell', { 'for': 'python' }\n~~~\n\n\n### [Vundle]\n\n~~~vim\nPlugin 'jpalardy/vim-slime'\nPlugin 'hanschen/vim-ipython-cell'\n~~~\n\n\n### [NeoBundle]\n\n~~~vim\nNeoBundle 'jpalardy/vim-slime', { 'on_ft': 'python' }\nNeoBundle 'hanschen/vim-ipython-cell', { 'on_ft': 'python' }\n~~~\n\n\n### [Dein]\n\n~~~vim\ncall dein#add('jpalardy/vim-slime', { 'on_ft': 'python' })\ncall dein#add('hanschen/vim-ipython-cell', { 'on_ft': 'python' })\n~~~\n\n\n### [Pathogen]\n\n~~~sh\ncd ~/.vim/bundle\ngit clone https://github.com/hanschen/vim-ipython-cell.git\n~~~\n\n[vim-plug]: https://github.com/junegunn/vim-plug\n[Vundle]: https://github.com/VundleVim/Vundle.vim\n[NeoBundle]: https://github.com/Shougo/neobundle.vim\n[Dein]: https://github.com/Shougo/dein.vim\n[Pathogen]: https://github.com/tpope/vim-pathogen\n\n\nUsage\n-----\n\nipython-cell sends code from Vim to IPython using [vim-slime]. For this to\nwork, IPython has to be running in a terminal multiplexer like GNU Screen or\ntmux, or in a Vim or Neovim terminal. I personally use tmux, but you will find\n`screen` installed on most *nix systems.\n\nIt is recommended that you familiarize yourself with [vim-slime] first before\nusing ipython-cell. Once you understand vim-slime, using ipython-cell will be a\nbreeze.\n\nipython-cell does not define any key mappings by default, but comes with the\ncommands listed below, which I recommend that you bind to key combinations of\nyour likings. The [Example Vim Configuration](#example-vim-configuration) shows\nsome examples of how this can be done.\n\nNote that the 'non-verbose' cell execution feature copies your code to the\nsystem clipboard. You may want to avoid using this feature if your code\ncontains sensitive data.\n\n\n### Commands\n\n| Command                               | Description                                                                                 |\n| ------------------------------------- | ------------------------------------------------------------------------------------------- |\n| `:IPythonCellExecuteCell`             | Execute the current code cell in IPython\u003csup\u003e1,2\u003c/sup\u003e                                      |\n| `:IPythonCellExecuteCellJump`         | Execute the current code cell in IPython, and jump to the next cell\u003csup\u003e1,2\u003c/sup\u003e           |\n| `:IPythonCellExecuteCellVerbose`      | Print and execute the current code cell in IPython\u003csup\u003e3\u003c/sup\u003e                              |\n| `:IPythonCellExecuteCellVerboseJump`  | Print and execute the current code cell in IPython, and jump to the next cell\u003csup\u003e3\u003c/sup\u003e   |\n| `:IPythonCellRun`                     | Run the whole script in IPython\u003csup\u003e1\u003c/sup\u003e                                                 |\n| `:IPythonCellRunTime`                 | Run the whole script in IPython and time the execution                                      |\n| `:IPythonCellClear`                   | Clear IPython screen                                                                        |\n| `:IPythonCellClose`                   | Close all figure windows                                                                    |\n| `:IPythonCellPrevCell`                | Jump to the previous cell header                                                            |\n| `:IPythonCellNextCell`                | Jump to the next cell header                                                                |\n| `:IPythonCellPrevCommand`             | Run previous command                                                                        |\n| `:IPythonCellRestart`                 | Restart IPython                                                                             |\n| `:IPythonCellInsertAbove`             | Insert a cell header tag above the current cell                                             |\n| `:IPythonCellInsertBelow`             | Insert a cell header tag below the current cell                                             |\n| `:IPythonCellToMarkdown`              | Convert current code cell into a markdown cell                                              |\n\n\u003csup\u003e1\u003c/sup\u003e Can be [configured for other REPLs](#other-repls).  \n\u003csup\u003e2\u003c/sup\u003e Non-verbose version (using `%paste`), requires Tkinter and `+clipboard` support or a [clipboard program](#supported-clipboard-programs).  \n\u003csup\u003e3\u003c/sup\u003e Verbose version (using `%cpaste`), works without Tkinter and clipboard support.\n\nFor the `IPythonCellExecuteCellVerbose` and `IPythonCellExecuteCellVerboseJump`\ncommands, you likely want to set\n\n~~~vim\nlet g:slime_python_ipython = 1\n~~~\n\nin your config to avoid potential issues with indentation.\nSee the [vim-slime documentation] for more information.\n\n[vim-slime]: https://github.com/jpalardy/vim-slime\n[vim-slime documentation]: https://github.com/jpalardy/vim-slime/blob/main/ftplugin/python/README.md\n\n\n### Custom commands\n\nYou may want to send other commands to IPython, such as `%debug` and `exit`.\nvim-slime makes it easy to send arbitrary text to IPython from Vim using the\n`SlimeSend1` command, for example\n\n    :SlimeSend1 %debug\n\nYou can then bind these commands to key mappings, see\n[Example Vim Configuration](#example-vim-configuration) below.\n\n\nDefining code cells\n-------------------\n\nCode cells are defined by either special text in the code or Vim marks,\ndepending on if `g:ipython_cell_delimit_cells_by` is set to `'tags'` or\n`'marks'`, respectively. The default is to use tags.\n\nThe examples below show how code cell boundaries work.\n\n\n### Code cells defined using tags\n\nUse `# %%`, `#%%`, `# \u003ccodecell\u003e`, or `##` to define cell boundaries.\n\n~~~\n                                   _\nimport numpy as np                  | cell 1\n                                   _|\n# %% Setup                          | cell 2\n                                    |\nnumbers = np.arange(10)             |\n                                   _|\n# %% Print numbers                  | cell 3\n                                    |\nfor n in numbers:                   |\n    print(n)                        |\n                                   _|\n    # %% Odd or even                | cell 4\n                                    |\n    if n % 2 == 0:                  |\n        print(\"Even\")               |\n    else:                           |\n        print(\"Odd\")                |\n                                   _|\n# %% Print sum                      | cell 5\n                                    |\ntotal = numbers.sum()               |\nprint(\"Sum: {}\".format(total))      |\nprint(\"Done.\")                     _|\n\n~~~\n\nNote that code cells can be defined inside statements such as `for` loops.\nIPython's `%paste` will automatically dedent the code before execution.\nHowever, if the code cell is defined inside e.g. a `for` loop, the code cell\n*will not* iterate over the loop.\n\nIn the example above, executing cell 4 after cell 3 will only print `Odd` once\nbecause IPython will execute the following code:\n\n~~~python\nfor n in numbers:\n    print(n)\n\n~~~\n\nfor cell 3, followed by\n\n~~~python\nif n % 2 == 0:\n    print(\"Even\")\nelse:\n    print(\"Odd\")\n\n~~~\n\nfor cell 4. The `for` statement is no longer included for cell 4.\n\nYou must therefore be careful when defining code cells inside statements.\n\n\n### Code cells defined using marks\n\nUse Vim marks (see `:help mark`) to define cell boundaries.\nHere marks are depicted as letters in the left-most column.\n\n~~~\n                                   _\n  | import numpy as np              | cell 1\n  |                                _| \na | numbers = np.arange(10)         | cell 2\n  |                                 |\n  |                                _|\nb | for n in numbers:               | cell 3\n  |     print(n)                   _|\nc |     if n % 2 == 0:              | cell 4\n  |         print(\"Even\")           |\n  |     else:                       |\n  |         print(\"Odd\")            |\n  |                                _|\nd | total = numbers.sum()           | cell 5\n  | print(\"Sum: {}\".format(total)) _|\n\n~~~\n\nSee note in the previous section about defining code cells inside statements\n(such as cell 4 inside the `for` loop in the example above).\n\n\nConfiguration\n-------------\n\n| Option                                | Description                                                                                                                                                                         |\n| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `g:ipython_cell_delimit_cells_by`     | Specify if cells should be delimited by `'tags'` or `'marks'`. Default: `'tags'`                                                                                                    |\n| `g:ipython_cell_tag`                  | If cells are delimited by tags, specify the format of the tags. Can be a string or a list of strings to specify multiple formats. Default: `['# %%', '#%%', '# \u003ccodecell\u003e', '##']`  |\n| `g:ipython_cell_regex`                | If `1`, tags specified by `g:ipython_cell_tag` are interpreted as [Python regex patterns], otherwise they are interpreted as literal strings. Default: `0`                          |\n| `g:ipython_cell_valid_marks`          | If cells are delimited by marks, specify which marks to use. Default: `'abcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'`                                                      |\n| `g:ipython_cell_cell_command`         | Command to run for executing cells. Default: `'%paste -q'`                                                                                                                          |\n| `g:ipython_cell_run_command`          | Command to run for executing scripts. Default: `'%run {options} \"{filepath}\"`\u003csup\u003e1\u003c/sup\u003e                                                                                           |\n| `g:ipython_cell_prefer_external_copy` | Set to `1` to prefer using an external program to copy to system clipboard rather than relying on Vim/Neovim yank. Default: `0`                                                     |\n| `g:ipython_cell_highlight_cells`      | Set to `0` to disable highlighting of cell headers defined using tags. Default: `1`                                                                                                 |\n| `g:ipython_cell_highlight_cells_ft`   | A list of filetypes for which cell headers will be highlighted if `g:ipython_cell_highlight_cells` is enabled. Default: `['python']`                                                |\n| `g:ipython_cell_send_cell_headers`    | If cells are delimited by tags, separately send the cell header before the cell contents. Default: `0`                                                                              |\n| `g:ipython_cell_insert_tag`           | The cell tag inserted by `IPythonCellInsertAbove` and `IPythonCellInsertBelow`. Default: `# %% `                                                                                    |\n| `g:ipython_cell_send_ctrl_c`          | Send `i` and Ctrl-C to enter insert mode and clear the prompt before sending commands to IPython. Set to `0` if this is not supported by your shell. Default: `1`                   |\n| `g:ipython_cell_send_ctrl_u`          | Send Ctrl-U to clear the line before sending commands to IPython. Default: `0`                                                                                                      |\n| `g:ipython_cell_update_file_variable` | Set to `1` to update the `__file__` variable in IPython when running cells. Default: `0`                                                                                            |\n| `g:ipython_cell_shell_prev_cmd`       | The preferred way to get the previous command in your shell, for example `'!!'`, `'fc -e: -1'`, or `'\u003cC-p\u003e'`\u003csup\u003e2\u003c/sup\u003e. Default: `'!!'`                                           |\n\n\u003csup\u003e1\u003c/sup\u003e `{options}` will be replaced by the command options, such as `-t` for `IPythonRunTime`. `{filepath}` will be replaced by the path of the current buffer.  \n\u003csup\u003e2\u003c/sup\u003e `\u003cC-p\u003e` (or `\u003cCtrl-P\u003e`; case-insensitive) will be replaced by the ANSI escape sequence corresponding to Ctrl-P.\n\n[Python regex patterns]: https://docs.python.org/3/library/re.html#regular-expression-syntax\n\n\nExample Vim configuration\n-------------------------\n\nHere's an example of how to configure your `.vimrc` to use this plugin. Adapt\nit to suit your needs.\n\n~~~vim\n\" Load plugins using vim-plug\ncall plug#begin('~/.vim/plugged')\nPlug 'jpalardy/vim-slime', { 'for': 'python' }\nPlug 'hanschen/vim-ipython-cell', { 'for': 'python' }\ncall plug#end()\n\n\"------------------------------------------------------------------------------\n\" slime configuration \n\"------------------------------------------------------------------------------\n\" always use tmux\nlet g:slime_target = 'tmux'\n\n\" fix paste issues in ipython\nlet g:slime_python_ipython = 1\n\n\" always send text to the top-right pane in the current tmux tab without asking\nlet g:slime_default_config = {\n            \\ 'socket_name': get(split($TMUX, ','), 0),\n            \\ 'target_pane': '{top-right}' }\n\nlet g:slime_dont_ask_default = 1\n\n\"------------------------------------------------------------------------------\n\" ipython-cell configuration\n\"------------------------------------------------------------------------------\n\" Keyboard mappings. \u003cLeader\u003e is \\ (backslash) by default\n\n\" map \u003cLeader\u003es to start IPython\nnnoremap \u003cLeader\u003es :SlimeSend1 ipython --matplotlib\u003cCR\u003e\n\n\" map \u003cLeader\u003er to run script\nnnoremap \u003cLeader\u003er :IPythonCellRun\u003cCR\u003e\n\n\" map \u003cLeader\u003eR to run script and time the execution\nnnoremap \u003cLeader\u003eR :IPythonCellRunTime\u003cCR\u003e\n\n\" map \u003cLeader\u003ec to execute the current cell\nnnoremap \u003cLeader\u003ec :IPythonCellExecuteCell\u003cCR\u003e\n\n\" map \u003cLeader\u003eC to execute the current cell and jump to the next cell\nnnoremap \u003cLeader\u003eC :IPythonCellExecuteCellJump\u003cCR\u003e\n\n\" map \u003cLeader\u003el to clear IPython screen\nnnoremap \u003cLeader\u003el :IPythonCellClear\u003cCR\u003e\n\n\" map \u003cLeader\u003ex to close all Matplotlib figure windows\nnnoremap \u003cLeader\u003ex :IPythonCellClose\u003cCR\u003e\n\n\" map [c and ]c to jump to the previous and next cell header\nnnoremap [c :IPythonCellPrevCell\u003cCR\u003e\nnnoremap ]c :IPythonCellNextCell\u003cCR\u003e\n\n\" map \u003cLeader\u003eh to send the current line or current selection to IPython\nnmap \u003cLeader\u003eh \u003cPlug\u003eSlimeLineSend\nxmap \u003cLeader\u003eh \u003cPlug\u003eSlimeRegionSend\n\n\" map \u003cLeader\u003ep to run the previous command\nnnoremap \u003cLeader\u003ep :IPythonCellPrevCommand\u003cCR\u003e\n\n\" map \u003cLeader\u003eQ to restart ipython\nnnoremap \u003cLeader\u003eQ :IPythonCellRestart\u003cCR\u003e\n\n\" map \u003cLeader\u003ed to start debug mode\nnnoremap \u003cLeader\u003ed :SlimeSend1 %debug\u003cCR\u003e\n\n\" map \u003cLeader\u003eq to exit debug mode or IPython\nnnoremap \u003cLeader\u003eq :SlimeSend1 exit\u003cCR\u003e\n\n\" map \u003cF9\u003e and \u003cF10\u003e to insert a cell header tag above/below and enter insert mode\nnmap \u003cF9\u003e :IPythonCellInsertAbove\u003cCR\u003ea\nnmap \u003cF10\u003e :IPythonCellInsertBelow\u003cCR\u003ea\n\n\" also make \u003cF9\u003e and \u003cF10\u003e work in insert mode\nimap \u003cF9\u003e \u003cC-o\u003e:IPythonCellInsertAbove\u003cCR\u003e\nimap \u003cF10\u003e \u003cC-o\u003e:IPythonCellInsertBelow\u003cCR\u003e\n\n~~~\n\nNote that the mappings as defined here work only in normal mode unless\notherwise noted (see `:help mapping` in Vim for more information).\n\nMoreover, these mappings will be defined for all file types, not just Python\nfiles. If you want to define these mappings for only Python files, you can put\nthe mappings in `~/.vim/after/ftplugin/python.vim` for Vim\n(or `~/.config/nvim/after/ftplugin/python.vim` for Neovim).\n\n\n### MATLAB-like key bindings\n\nIf you come from the MATLAB world, you may want e.g. F5 to save and run the\nscript regardless if you are in insert or normal mode, F6 to execute the\ncurrent cell, and F7 to execute the current cell and jump to the next cell:\n\n~~~vim\n\" map \u003cF5\u003e to save and run script\nnnoremap \u003cF5\u003e :w\u003cCR\u003e:IPythonCellRun\u003cCR\u003e\ninoremap \u003cF5\u003e \u003cC-o\u003e:w\u003cCR\u003e\u003cC-o\u003e:IPythonCellRun\u003cCR\u003e\n\n\" map \u003cF6\u003e to evaluate current cell without saving\nnnoremap \u003cF6\u003e :IPythonCellExecuteCell\u003cCR\u003e\ninoremap \u003cF6\u003e \u003cC-o\u003e:IPythonCellExecuteCell\u003cCR\u003e\n\n\" map \u003cF7\u003e to evaluate current cell and jump to next cell without saving\nnnoremap \u003cF7\u003e :IPythonCellExecuteCellJump\u003cCR\u003e\ninoremap \u003cF7\u003e \u003cC-o\u003e:IPythonCellExecuteCellJump\u003cCR\u003e\n\n~~~\n\n\n### Use the `percent` format\n\nIf you use the [percent format] for cells and don't want e.g. `# %% [markdown]`\nto be interpreted as a cell header, you can use regex:\n\n~~~vim\nlet g:ipython_cell_regex = 1\nlet g:ipython_cell_tag = '# %%( [^[].*)?'\n\n~~~\n\n[percent format]: https://jupytext.readthedocs.io/en/latest/formats.html#the-percent-format\n\n\n### Other REPLs\n\nipython-cell can also be configured to support other languages and REPLs.\nFor example, to make `IPythonCellRun` and `IPythonCellExecuteCell` work with\nJulia, add the following to your `.vimrc`:\n\n~~~vim\nlet g:ipython_cell_run_command = 'include(\"{filepath}\")'\nlet g:ipython_cell_cell_command = 'include_string(Main, clipboard())'\n\n~~~\n\nIf you use Windows, you may have to change the first line to\n\n~~~vim\nlet g:ipython_cell_run_command = 'include(raw\"{filepath}\")'\n\n~~~\n\nto deal with `\\` path separators.\n\n\n### Change highlight for code cell headers\n\nTo change the colors of cell headers, add something like the following to your\n.vimrc:\n\n    augroup ipython_cell_highlight\n        autocmd!\n        autocmd ColorScheme * highlight IPythonCell ctermbg=238 guifg=darkgrey guibg=#444d56\n    augroup END\n\n\n### More tips\n\nFor more configuration and usage tips, see [the wiki].\n\n[the wiki]: https://github.com/hanschen/vim-ipython-cell/wiki\n\n\nSupported clipboard programs\n----------------------------\n\nIf your Vim installation does not have `+clipboard` support, some features of\nipython-cell will attempt to use one of the following clipboard programs:\n\n* Linux: [xclip] (preferred) or [xsel].\n* macOS: pbcopy (installed by default).\n* Windows: not supported.\n\n[xclip]: https://github.com/astrand/xclip\n[xsel]: https://github.com/kfish/xsel\n\n\nFAQ\n---\n\n\u003e I have installed the plugin but get 'Not an editor command'. Why?\n\nIf the error persists after restarting Vim/Neovim, make sure that your editor\nhas support for Python by running the following commands in the editor:\n\n    :echo has('python')\n    :echo has('python3')\n\nAt least one of the commands should return `1`. If they both return `0`,\nyou need to set up your editor with Python support. In the case of Neovim, that\nmeans installing the `pynvim` Python module, see [documentation].\n\n[documentation]: https://neovim.io/doc/user/provider.html#provider-python\n\n\u003e Why does this plugin not work inside a virtual environment?\n\nIf you use Neovim, make sure you have the [pynvim] Python package installed for\nyour Python provider:\n\n    pip install pynvim\n\nTo avoid having to install pynvim for every virtual environment, you can use\nthe `g:python3_host_prog` variable to set a specific interpreter path, e.g.:\n\n    let g:python3_host_prog = '/usr/bin/python'\n\n[pynvim]: https://pypi.org/project/pynvim/\n\n\u003e The `IPythonCellExecuteCell` and `IPythonCellExecuteCellJump` commands do\n\u003e not work, but other commands such as IPythonCellRun work. Why?\n\nFirst, make sure you have Tkinter installed (otherwise you will get an error\nmessage) and a supported [clipboard program](#supported-clipboard-programs).\nAlso make sure your `DISPLAY` variable is correct, see next question.\nIf you cannot install the requirements but still want to use the cell execution\nfeature, you can try the verbose versions `IPythonCellExecuteCellVerbose` and\n`IPythonCellExecuteCellVerboseJump`.\n\n\u003e `IPythonCellExecuteCell` and `IPythonCellExecuteCellJump` do not execute the\n\u003e correct code cell, or I get an error about\n\u003e 'can't open display',\n\u003e 'could not open display',\n\u003e 'could not connect to display',\n\u003e or something similar, what do I do?\n\nMake sure your `DISPLAY` environment variable is correct, especially after\nre-attaching a screen or tmux session. In tmux you can update the `DISPLAY`\nvariable with the following command:\n\n    eval $(tmux showenv -s DISPLAY)\n\n\u003e I get an error message saying `ERROR! Session/line number was not unique in\n\u003e database. History logging moved to new session \u003csome number\u003e`, why?\n\nThis is due to a [bug] in IPython. Upgrading to IPython 8.8.0 or newer or\ndowngrading to IPython 8.1.1 should fix the issue.\n\n\u003e Should I use tags or marks to define cells?\n\nThis depends on personal preference. Tags are similar to `%%` in MATLAB and\n`# %%` in e.g. Jupyter Notebooks and Spyder. They become a part of your code\nand can also be shared with others, making them ideal if you want more\npersistent cells. Marks, on the other hand, are more transient and can be\nchanged without triggering changes in your code, which can be nice if you\nchange your cells often and your code is under version control.\n\n\u003e How do I show the marks in the left-most column?\n\nUse the vim-signature plugin: https://github.com/kshenoy/vim-signature\n\n\u003e How to send only the current line or selected lines to IPython?\n\nUse the features provided by vim-slime, see the\n[Example Vim Configuration](#example-vim-configuration) for an example.\nThe default mapping `C-c C-c` (hold down Ctrl and tap the C key twice) will\nsend the current paragraph or the selected lines to IPython. See `:help slime`\nfor more information, in particular the documentation about\n`\u003cPlug\u003eSlimeRegionSend` and `\u003cPlug\u003eSlimeLineSend`.\n\n\u003e Why do I get \"name 'plt' is not defined\" when I try to close figures?\n\nipython-cell assumes that you have imported `matplotlib.pyplot` as `plt` in\nIPython. If you prefer to import `matplotlib.pyplot` differently, you can\nachieve the same thing using vim-slime, for example by adding the following to\nyour .vimrc:\n\n    nnoremap \u003cLeader\u003ex :SlimeSend1 matplotlib.pyplot.close('all')\u003cCR\u003e\n\n\u003e How can I send other commands to IPython, e.g. '%who'?\n\nYou can easily send arbitrary commands to IPython using the `:SlimeSend1`\ncommand provided by vim-slime, e.g. `:SlimeSend1 %who`, and map these commands\nto key combinations.\n\n\u003e The `IPythonCellExecuteCell` command does not work, it seems to run the wrong\n\u003e cell.\n\nTry to add the following to your configuration file:\n\n    let g:ipython_cell_prefer_external_copy = 1\n\nMake sure you have a [supported clipboard program](#supported-clipboard-programs)\ninstalled.\n\n\u003e Why isn't this plugin specific to Python by default? In other words, why do\n\u003e I have to add all this extra stuff to make this plugin Python-specific?\n\nThis plugin was created with Python and IPython in mind, but I don't want to\nrestrict the plugin to Python by design. Instead, I have included examples of\nhow to use plugin managers to specify that the plugin should be loaded only\nfor Python files and how to create Python-specific mappings. If someone wants\nto use this plugin for other filetypes, they can easily do so.\n\n\u003e Why is this plugin written in Python instead of pure Vimscript?\n\nBecause I feel more comfortable with Python and don't have the motivation to\nlearn Vimscript for this plugin. If someone implements a pure Vimscript\nversion, I would be happy to consider to merge it.\n\n\u003e I get an error (e.g. SyntaxError) because the plugin inserts `^U` before the\n\u003e command, what should I do?\n\nTry to add the following to your configuration file:\n\n    let g:ipython_cell_send_ctrl_u = 0\n\n\u003e The restart command `IPythonCellRestart` does not work. It terminates an\n\u003e IPython session instead of restarting the kernel.\n\nTry to change the way you get the previous command in your shell. For example,\n\n    \"\" Substitute '\u003cC-p\u003e' for '!!'.\n    let g:ipython_cell_shell_prev_cmd = '\u003cC-p\u003e'\n    \"\" The following is also valid:\n    \" let g:ipython_cell_shell_prev_cmd = '\u003cCtrl-P\u003e'\n\n[bug]: https://github.com/ipython/ipython/issues/13622\n\n\nRelated plugins\n---------------\n\n* [tslime\\_ipython] - Similar to ipython-cell but with some small differences.\n  For example, tslime\\_ipython pastes the whole code that's sent to IPython\n  to the input line, while ipython-cell uses IPython's `%paste -q` command to\n  make the execution less verbose.\n* [vim-ipython] - Advanced two-way integration between Vim and IPython. I never\n  got it to work as I want, i.e., don't show the code that's executed but show\n  the output from the code, which is why I created this simpler plugin.\n* [nvim-ipy] - Similar to [vim-ipython], but refactored for Neovim and has some\n  basic support for cells.\n* [vim-tmux-navigator] - Seamless navigation between Vim splits and tmux panes.\n* [vim-signature] - Display marks in the left-hand column.\n\n[tslime\\_ipython]: https://github.com/eldridgejm/tslime_ipython\n[vim-ipython]: https://github.com/ivanov/vim-ipython\n[nvim-ipy]: https://github.com/bfredl/nvim-ipy\n[vim-tmux-navigator]: https://github.com/christoomey/vim-tmux-navigator\n[vim-signature]: https://github.com/kshenoy/vim-signature\n\n\nThanks\n------\n\nipython-cell was heavily inspired by [tslime\\_ipython].\nThe code logic to determine which Python version to use was taken from\n[YouCompleteMe].\n\n[tslime\\_ipython]: https://github.com/eldridgejm/tslime_ipython\n[YouCompleteMe]: https://github.com/Valloric/YouCompleteMe\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanschen%2Fvim-ipython-cell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanschen%2Fvim-ipython-cell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanschen%2Fvim-ipython-cell/lists"}