4 ms·
Evaluate Markdown code blocks within Vim
- djaouen 2y ago[flagged]
- dvdkon 2y agoI like the feature that allows you to put a block's output into another block. I've been toying with the idea of self-modifying/self-introspecting documents for some time, and I think they're a good concept for ad-hoc files in the space between prose, scripts, and databases.
- jasonventresca 2y agoThis is definitely helpful! Thank you for building it : )
- trees101 2y agolooks like a nice tool for evaluating code blocks directly in Vim's Markdown buffers, and the ability to redirect outputs into named blocks is a cool way to keep everything contained in the editor. If you're looking for something similar but more versatile across different environments, check out *Cog*. It embeds executable code in any text file and inserts the output back into the document, which is great for automating documentation outside of Vim, especially in CI pipelines.
- VTimofeenko 2y agoMdsh also works great in CI-like context[1], but I don't think it can eval per block. Definitely trying out medieval for those odd "I want to run this one thing from a README but I don't wanna leave vim" cases. [1]: https://github.com/zimbatm/mdsh https://github.com/zimbatm/mdsh
- metadat 2y agoHow can you execute the current buffer line as a vim command? I have this shortcut on one of my machines, but it's really tough to search the Internet for. It's so useful for one-off report generation, I use it daily on my (last remaining) Windoze machine. Vomscript isn't that bad! Not any worse than Bash, haha. It turns out that you can get plenty done with only arrays and without a native Map data structure. If you get desperate, use SQLite. *Grin*
- jmholla 2y agoThis should do it (without the spaces): : C-r C-l <Enter> The `C-l` buffer is the line you are currently on in command mode. (Might be in other modes too.)
- metadat 2y agoBravo!
- qazxcvbnm 2y agoAnother way: yy@" In other words, execute the " register (what you just copied) as a macro. In the same vein, yy@0 would work as well (the 0 register is the last yank). Also, what do you mean without a native map structure? Vimscript has Dictionaries just fine.
- abdullahkhalids 2y agoI created something similar in emacs for markdown [1,2]. The real feature needed is to connect to ipython, so images etc can be embedded into the markdown file as a image link. Don't know how to do this. [1] https://gist.github.com/abdullahkhalids/83055b1abbd2cdf2416a480d046136e1 https://gist.github.com/abdullahkhalids/83055b1abbd2cdf2416a... [2] Yes, I know about org-mode and I do use it.
- setopt 2y agoI use comint-mime [0] to show images in IPython buffers started with `M-x run-python`. [0]: https://github.com/astoff/comint-mime https://github.com/astoff/comint-mime
- abdullahkhalids 2y agoThank you. This is very nice. The short code is very readable and tells me how to integrate ipython correctly.
- kolja005 2y agoRelated: I found out about a vim/neovim plugin called Molten[1] that tries to be a replacement for Jupyter Notebooks in the terminal. It was a little rough around the edges ~5 months ago when I tried it, but looking at the repo it seems its still being actively developed, so maybe that's changed. IIRC it uses an ipynb server to keep track of each cell's outputs. I quite enjoyed using it as someone who doesn't need notebooks very often and loathes leaving my terminal setup. [1] https://github.com/benlubas/molten-nvim https://github.com/benlubas/molten-nvim
- zJayv 2y agorelated project: https://github.com/joouha/euporie https://github.com/joouha/euporie
- aphantastic 2y agoThe “Handy Dandy Notebook” is similar for VS Code, with support for Knuthian literate programming.
- swah 2y agoHave to install to check if there is a config to execute on every keystroke (thats reasonable, right?)
- aeonik 2y agoWhat I really want is a Notebook experience for the terminal, but output is for each command is automatically stored in separate buffers. Then I can tweak commands, or chain the input from the buffers. (automatically using mkfifo or something) I want my command to history stored in another buffer, and another buffer that I can quickly move the commands and/or output to a script or a markdown document for documentation. That way I can quickly debug or build scripts, or perform analysis, and it will automatically have an executable to reproduce all my steps.
- d0mine 2y agoOrg Babel: “Because the return value of a function written in one language can be passed to a function written in another language, or to an Org table, which is itself programmable, Babel can be used as a meta-functional programming language. With Babel, functions from many languages can work together. You can mix and match languages, using each language for the tasks to which it is best suited.” https://orgmode.org/worg/org-contrib/babel/intro.html https://orgmode.org/worg/org-contrib/babel/intro.html Jupyter is one of the supported languages. https://github.com/emacs-jupyter/jupyter?tab=readme-ov-file#org-mode-source-blocks https://github.com/emacs-jupyter/jupyter?tab=readme-ov-file#...
- sevensor 2y agoI’m going to link to my own comment here: https://news.ycombinator.com/item?id=41945124 https://news.ycombinator.com/item?id=41945124 This is super easy in kakoune, requires few keystrokes and no customization, and can be done in any kind of buffer.