[HN Gopher] Evaluate Markdown code blocks within Vim
       ___________________________________________________________________
        
       Evaluate Markdown code blocks within Vim
        
       Author : pentestercrab
       Score  : 62 points
       Date   : 2024-10-26 12:08 UTC (3 days ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | dvdkon wrote:
       | I 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 wrote:
       | This is definitely helpful! Thank you for building it : )
        
       | trees101 wrote:
       | looks 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 wrote:
       | Mdsh 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
        
       | metadat wrote:
       | How 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 wrote:
         | This 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 wrote:
           | Bravo!
        
         | qazxcvbnm wrote:
         | Another 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 wrote:
       | I 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/83055b1abbd2cdf2416a...
       | 
       | [2] Yes, I know about org-mode and I do use it.
        
         | setopt wrote:
         | I use comint-mime [0] to show images in IPython buffers started
         | with `M-x run-python`.
         | 
         | [0]: https://github.com/astoff/comint-mime
        
           | abdullahkhalids wrote:
           | Thank you. This is very nice. The short code is very readable
           | and tells me how to integrate ipython correctly.
        
       | kolja005 wrote:
       | Related: 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
        
         | zJayv wrote:
         | related project: https://github.com/joouha/euporie
        
       | aphantastic wrote:
       | The "Handy Dandy Notebook" is similar for VS Code, with support
       | for Knuthian literate programming.
        
         | swah wrote:
         | Have to install to check if there is a config to execute on
         | every keystroke (thats reasonable, right?)
        
       | aeonik wrote:
       | What 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.
        
       | sevensor wrote:
       | I'm going to link to my own comment here:
       | 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.
        
       ___________________________________________________________________
       (page generated 2024-10-29 23:02 UTC)