Vim/Neovim plugin for editing Jupyter notebook (ipynb) files through notedown.
http://www.vim.org/scripts/script.php?script_id=5506
This plugin is obsolete: use jupytext.vim instead
- Copy the
ipynb_notedown.vimscript to your vim plugin directory (e.g.$HOME/.vim/plugin). Refer to:help add-plugin,:help add-global-pluginand:help runtimepathfor more details about Vim plugins. - Restart Vim.
When you open a Jupyter Notebook (*.ipynb) file, it is automatically
converted from json to markdown through the notedown utility. Upon saving
the file, the content is converted back to the json notebook format.
The purpose of this plugin is to allow editing notebooks directly in vim.
The conversion json → markdown → json is relatively lossless, although
some of the restrictions of the notedown utility apply. In particular,
notebook and cell metadata are lost, and consecutive markdown cells are
merged into one cell.
The following settings in your ~/.vimrc may be used to configure the
plugin:
-
g:notedown_enable=1You may disable the automatic conversion between the notebook json format and markdown (i.e., deactivate this plugin) by setting this to 0.
-
g:notedown_code_match='all'Value for the
--matchcommand line option ofnotedown. There are known problems with using the value 'strict', but 'fenced' may be a good alternative if you need code blocks in markdown.
The jupytext utility is an alternative to notedown that has considerably less shortcomings. In particular, it guarantees the roundtrip conversion ipynb → markdown → ipynb to be lossless (metadata is preserved, consecutive markdown cells are possible). This is achieved by the markdown file containing only the notebook inputs, and the conversion back to the notebook format using the data from the original notebook file for the outputs. The jupytext.vim plugin provides similar capabilities to ipynb_notedown.vim, but using jupytext instead of notedown by default. If you still want to use notedown over jupytext, e.g. because you need cell outputs to be contained in the markdown representation, you can still use the new jupytext.vim plugin, with the following custom configuration in your ~/.vimrc:
let g:jupytext_command = 'notedown'
let g:jupytext_fmt = 'markdown'
let g:jupytext_to_ipynb_opts = '--to=notebook'
Thus, jupytext.vim supersedes the ipynb_notedown.vim entirely, and should be used instead of it.