Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vim binding? #5

Open
dewoller opened this issue May 16, 2020 · 1 comment
Open

Vim binding? #5

dewoller opened this issue May 16, 2020 · 1 comment

Comments

@dewoller
Copy link

Hey Miles, I love your work (and coding style). Any chance of a VIM binding? Or a little bit of documentation about how it works. I am a bit daunted by the ESS bindings (although it appears more principled than the vimscript).

Cheers

@MilesMcBain
Copy link
Owner

Thanks for the compliment! And don't worry, the ESS binding is not completely clear to me at this point :)

I think the main thing you need to know is the interface to the fnmate machinery. If you want to create a vim binding for a template in a new file, then your aim is to call:

fnmate_fn.R(text, index), where:

  • text is some lines of text that surround the cursor above and below. For example, 10 above, the cursor line, and 10 below (21 total). They'll be concatenated into one long vector.
  • and index is a 1-indexed position into that text vector that corresponds to the cursor position.

I don't know vimscript or how the interface to vim and R works. So I can't be much help, but in Emacs I resorted to pasting in the text as a literal argument. Like:

fnmate_fn.R("all the lines\\nOf text", 1)

A bit of annoying math might be required to calculate the index depending on what facilities you have in Vim. You could use the R code I have for the RStudio addin as a guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants