1 Introduction
Start with youtube Chris T.
https://www.youtube.com/watch?v=lwD8G1P52Sk
Start on zz.tools.vim-R.vim
Here is the code for the plugin:
function! SelectChunk() :execute “normal! ?{\<cr>jV/
<cr>k” endfunction
function! MoveNextChunk() :execute “normal! /```{<CR>j” :noh endfunction
function! MovePrevChunk() :execute “normal! 2?```{<CR>j” :noh endfunction
function! Raction(action) :let @c = expand(“
function! SubmitLine() :let @c = getline(“.”) . “” :call term_sendkeys(term_list()[0], @c) endfunction ” function! GetVisualSelection(mode) ” call with visualmode() as the argument let [line_start, column_start] = getpos(“‘<“)[1:2] let [line_end, column_end] = getpos(”’>”)[1:2] let lines = getline(line_start, line_end) if a:mode ==# ‘v’ ” Must trim the end before the start, the beginning will shift left. let lines[-1] = lines[-1][: column_end - (&selection == ‘inclusive’ ? 1 : 2)] let lines[0] = lines[0][column_start - 1:] elseif a:mode ==# ‘V’ else return ’’ endif return join(lines, “”) endfunction
function! Submit() :let y = “source(‘source_visual’,echo=T)” . “” :call term_sendkeys(term_list()[0], y) ” :call delete(‘source_visual’) endfunction
function! Sel() :let @c= GetVisualSelection(visualmode()) . “” :call writefile(getreg(‘c’, 1, 1), “source_visual”) endfunction
function! Brk() :call term_sendkeys(term_list()[0], “<c-c>”) endfunction
function! SubmitEmbed() :let y = “sink(‘temp.txt’); source(‘source_visual’,echo=T); sink()” . “” :call term_sendkeys(term_list()[0], y) ” :call delete(‘source_visual’) endfunction
function! Rd() !sed ‘s/^/# /g’ temp.txt > temp_commented.txt :r !cat temp_commented.txt endfunction
augroup r_rmd_qmd autocmd! autocmd FileType r,rmd,qmd nnoremap
2 Experiment
2.1 Title: Add the normal mode mapping ZY
for quarto
files.
2.2 Introduction:
The goal is to allow quarto
filetypes to render to pdf
using a mapping called from the qmd
file.
start by constructing a mapping in .
vimrc
: (easier to develop there) mapZY
to a shell escape and call toquarto_render
. ( useZT
map inrgt-R.vim
as a template).test using any
index.qmd
file in posts. e.g.~/config_ultisnips/index.qmd
.once the mapping works then move it to the plugin and add a autocommand that only adds the mapping for quarto filetype files.
open
~/prj/qblog/posts/vim_plugin_zz.tools.vim-R/rgt-R/plugin/rgt-R.vim
copy
ZT
mapping toZY
modify
ZY
to renderquarto
files withrender_quarto
command.
3 Experiment 2
There are two functions in rgt-R that need investigating: 1. SubmitSel and 2. GetVisualSelection
This experiment is to explore and document why SubmitSel sends p copies of the command “source(‘temp.R’) to the R interpreter, where p is the number of lines in the selection.
type(foo) returns code for type of foo. 1 for string, 3 for list
3.1 Prerequisites
In development
3.2 Step-by-Step Implementation
In development
3.3 Key Takeaways
In development
3.4 Further Reading
In development
Reuse
Citation
@online{(ryy)_glenn_thomas2025,
author = {(Ryy) Glenn Thomas, Ronald},
title = {A Simple Vim Package for Interfacing with a {REPL}},
date = {2025-05-13},
url = {https://focusonr.org/posts/simple_vim_plugin/},
langid = {en}
}