jakethekoenig / ChatVim

Talk to GPT in Vim!
13 stars 0 forks source link

**Title**: Implement Functions to Extract and Handle Code from Markdown in Vim #5

Open mentatbot[bot] opened 5 months ago

mentatbot[bot] commented 5 months ago

Description: This PR introduces two new functions to the chatvim.py plugin for Vim, enhancing the handling of code blocks within Markdown files. The functions are designed to streamline the process of extracting code from Markdown and managing it within the Vim environment.

Changes:

  1. ExtractCodeFromMarkdown: This function extracts code from Markdown code blocks and stores it in a specified Vim register. It toggles the detection of code blocks upon encountering triple backticks (```). The extracted code is then stored in the specified register, or the default register if none is specified.

  2. PasteCodeToNewFile: After extracting code with the ExtractCodeFromMarkdown function, this function facilitates the creation of a new buffer, pastes the code from the specified register, and saves the buffer as llm_code.py. This function simplifies the workflow of handling code snippets extracted from Markdown documents, making it easier to save and edit them as standalone Python files.

Usage:

Benefits:

This enhancement is particularly useful for developers and writers who frequently work with Markdown documents and need an efficient way to manage code snippets embedded within these documents.

Closes #4