1

If you convert a Jupyter Notebook to a markdown document (with pandoc, for example) then it's nice and easy to edit it without having to launch the browser. I enjoy the vim-markdown plugin for this work.

I have since found the jupyter-vim plugin, which can send python code snippets directly from vim to a jupyter-qtconsole (far more light-weight than the Jupyter notebook). My problem is that vim only activates the jupyter-vim plugin for a "python" filetype, so I can't use it when editing a markdown file. But I don't see any reason I shouldn't be able to use the plugin from a markdown file to send the qtconsole code snippets from a fenced python code block, for exampe.

I'm almost sure there's a way to do this, but I have not figured it out. I tried, for example, making a 'markdown' directory in the ~/.vim/bundle/jupyter-vim/ftplugin/ directory. But I'm shooting in the dark. I can't see how to do this in vim help for :h filetype-plugins.

Any ideas would be most welcome...!

1 Answer 1

1

After looking in ~/.vim/bundle/jupyter-vim/plugin/jupyter.vim, I found the call I needed that initializes the jupyter plugin.

In vim, with my markdown file open, I just need to :call jupyter#load#MakeStandardCommands().

Now it works -- I essentially have a Jupyter Notebook running in vim!

If you do this you'll probably also want to

let g:jupyter_cell_separators = ['```']

in .vimrc. Then a fenced code block is run like a cell in Jupyter.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.